bruensicke/li3_mustache

Lithium库用于渲染mustache模板

安装: 28

依赖者: 1

建议者: 0

安全: 0

星星: 5

关注者: 3

分支: 6

开放问题: 0

类型:lithium-library

dev-master 2013-08-29 07:29 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:59:40 UTC


README

Lithium库用于解析mustache视图,使用PHP Mustache

Mustache规范版本:1.1.2 PHP Mustache版本:1.0.0

安装

将子模块添加到您的li3库中

git submodule add git@github.com:bruensicke/li3_mustache.git libraries/li3_mustache

并在您的应用程序中激活它(config/bootstrap/libraries.php),当然

Libraries::add('li3_mustache');

使用方法

在您的视图中,您可以使用有帮助的mustache助手轻松使用mustache元素

<?= $this->mustache->render('posts/detail', compact('post')); ?>

然后将从 {:library}/views/mustache/posts/detail.html.php 拖取mustache模板

任何传递的模型(或模型集合)将在此刻转换为数组数据,以允许轻松使用。我将努力实现模型回调解决方案,允许调用模板函数。

如果您想提供供js使用的mustache模板,可以这样做

<?= $this->mustache->script('posts/index'); ?>

这将渲染以下javascript块(包括模板)

<script id="tpl_posts_index" type="text/html" charset="utf-8"> { mustache template here } </script>

您可以使用此模板,使用 tpl_ 后跟 Inflector::slugified 模板名称(其中 - 将变为 _)。

附加使用方法

我更喜欢在视图中使用mustache模板来表示所有类型的数据,而不是只使用mustache作为一般视图,我将视图本身保留为默认的html/php混合。但此库还附带了一个mustache视图类,以完全使用mustache视图。

待办事项

以下是我的路线图。如果您需要这些功能中的任何一个,请尽早告知。

  • [✓] 提供有用的助手
  • [✓] 允许轻松使用元素作为mustache模板
  • [✓] mustache模板文件夹位于views/mustache
  • [✓] 允许mustache模板位于库中
  • [✓] 允许渲染子模板,无需注册
  • 提供包含li3相关信息的额外作用域(例如,请求、会话等)
  • 允许在集合数据上调用模型方法回调

致谢

请在此处报告任何错误:https://github.com/bruensicke/li3_mustache/issues