定制 hypejunction/mustache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hypejunction/mustache

最新稳定版本:1.0.0

Composer 安装命令:

composer require hypejunction/mustache

包简介

Mustache templating in Elgg

README 文档

README

Elgg 2.0

Features

  • Templates can be rendered both client and server side
  • Compatible with Elgg's view system
  • AMD-friendly

Usage

  1. Create a new template as an Elgg view
// /my_plugin/views/default/path/to/template.html
<div class="mustache-template">
	<h3>Hello, <b>{{name}}</b></h3>
</div>

You can also use PHP views, e.g. template.html.php. This allows you to call other views and do stuff with PHP. If you use this approach, be sure to register the template views in simplecache, so that they are accessible with AMD.

// /start.php
elgg_register_simplecache_view('path/to/template.html.php');
// /my_plugin/views/default/path/to/template.html.php
<div class="mustache-template">
	<h3>Hello, <b>{{name}}</b></h3>
	<?= elgg_view('path/to/other/template.html') ?>
</div>
  1. Render server-side
	echo mustache()->render(elgg_view('mustache/template.html'), array(
		'name' => elgg_get_logged_in_user_entity()->name,
	));
  1. Render client-side
define(function(require) {

	var elgg = require('elgg');
	var mustache = require('mustache');
	var template = require('text!mustache/template.html');

	var view = mustache.render(template, {
		name: elgg.get_logged_in_user_entity().name
	});

	$('body').html(view);

});

Docs

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-10-05