modulargaming/kostache

Kohana v3 的无逻辑视图/Mustache 模块

安装次数: 6,318

依赖项: 1

建议者: 0

安全性: 0

星标: 0

关注者: 5

分支: 44

类型:kohana-module

v1.0.0 2013-07-26 16:15 UTC

This package is not auto-updated.

Last update: 2024-09-23 15:05:13 UTC


README

Kostache 是一个用于在您的应用程序中使用 Mustache 模板 Kohana 3 模块。

使用方法

要使用它,只需创建一个像这样的 POPO (Plain Old PHP Object)

<?php

class View_Test
{
	public $hello = 'world';

	public function testing()
	{
		return 'foobar';
	}
}

然后创建一个 mustache 渲染器。引擎方法中的参数是要使用的模板名称。

<?php

$renderer = Kostache::factory();

然后渲染它

<?php

$this->response->body($renderer->render(new View_Test));

模板

模板应放在您的文件系统中的 templates/ 目录下。它们应该具有 .mustache 扩展名。

部分

部分将根据模板中使用的名称自动加载。所以如果你在模板中引用 {{>foobar}},它将在 templates/partials/foobar.mustache 中寻找该部分。

布局

KOstache 支持布局。要使用,只需添加一个 templates/layout.mustache 文件(已经提供了一个简单的文件),然后使用 Kostache_Layout 而不是 Kostache 作为渲染器。你可能想在视图类中放一个 $title 属性。布局应包括一个 {{>content}} 部分以渲染页面的主体。

更多信息

有关具体用法和文档,请参阅

PHP Mustache

原始 Mustache