食堂/解析器

此包已被废弃且不再维护。未建议替代包。

用于渲染HTML模板的简单引擎。

1.0.4 2014-02-22 00:00 UTC

This package is not auto-updated.

Last update: 2020-01-20 03:38:51 UTC


README

#Canteen 解析器

Canteen 解析器是一个用于管理、加载和渲染模板的库。有关代码库的文档,请参阅Canteen 解析器文档

##安装

可以使用Composer进行安装。

composer require canteen/parser dev-master

包括在您的索引中使用Composer自动加载器。

require 'vendor/autoload.php';

##示例用法

use Canteen\Parser\Parser;
$parser = new Parser();

// Load an optional list of templates
$parser->addTemplate('MyTemplate', 'MyTemplate.html');

// Render the template with some substitutions
echo $parser->template(
	'MyTemplate',
	[
		'title' => 'My Page',
		'description' => 'Description goes here!'
	]
);

MyTemplate.html的内容

	<h1>{{title}}</h1>
	<div class="description">{{description}}</div>

将输出

	<h1>My Page</h1>
	<div class="description">Description goes here!</div>

###重建文档

此库使用YUIDoc自动生成文档。要安装YUIDoc,请运行sudo npm install yuidocjs。此外,这还需要项目CanteenTheme与此存储库一起检出。要重建文档,请在命令行中运行ant任务。

ant docs

##许可协议##

版权所有 (c) 2013 Matt Karl

在MIT许可下发布。