crazedsanity/template 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

crazedsanity/template

最新稳定版本:v0.4.8

Composer 安装命令:

composer require crazedsanity/template

包简介

Templating library.

README 文档

README

Template system, based on cs_genericPage from cs-content (v1.x).

This is a templating engine, built primarily to allow easy separation between PHP and HTML. Separating PHP from HTML helps keep the code clean and tends to avoid spaghetti code from happening.

Quick Definitions

Template: a file containing template vars.

Template Var: a string of text, following standard variable naming conventions, wrapped in curly braces: {templateVar}

Sample

This is a simple example. Keep in mind that there's a lot of different ways to accomplish this same end result.

$recordSet = array(
			0 => array(
				'primary_id'    => 1,
				'record_name'   => 'The First Record',
				'another_field' => 'field value',
				'is_active'     => 0,
			),
			1 => array(
				'primary_id'    => 3,
				'record_name'   => 'A third record',
				'another_field' => 'something else',
				'is_active'     => 1,
			),
);
$tmpl = new Template(__DIR__ .'/path/to/file.tmpl');
$output = $tmpl->renderRows($recordSet);

The associated template file would look something like this:

===============
{primary_id}|{record_name}|{another_field}|{is_active}|{invalid_field}
----

The output would look like this:

===============
1|The First Record|field value|0|
----
===============
3|A third record|something else|1|
----

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-11