承接 losthost/template-helper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

losthost/template-helper

最新稳定版本:v1.0.0

Composer 安装命令:

composer require losthost/template-helper

包简介

A helper class to use php-templates

README 文档

README

Loads and displays or processes a template file

Very simple usage

use losthost\templateHelper\Template;

$template = new Template('template-file.tpl');
$template->display(); 

This will display the content of file templates/default/template-file.tpl. It seems not very usefull, so you can create more complex templates as in next example.

More complex usage

Create a template file ex. templatex/default/simple-template.tpl with code:

Hello <?=$name; ?>!

Now to display "Hello John!" do the following:

use losthost\templateHelper\Template;

$template = new Template('simple-template.tpl');
$template->assing('name', 'John');
$template->display();

Multilang usage

Use $template = new Template('template.tpl', 'de'); to use templates in templates/de/ instead of templates/default/.

You can change default templates dir from templates/ to anydir/ you want by using

$template->setTemplateDir('anydir')

Do not display output

Sometimes you don't want to display output. You may need just to get the template output for further processing. Use this:

$result = $template->process(); // insead of $template->display();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-10-06