Skip to content

tzmfreedom/php-mytemplate-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

My PHP Template Engine

PHP Template Engine

Install

$ composer config repositories.tzmfreedom/php-mytemplate-engine vcs https://github.com/tzmfreedom/php-mytemplate-engine
$ composer require tzmfreedom/php-mytemplate-engine:dev-master

Usage

<?php

require_once 'vendor/autoload.php';

$engine = new \MyTemplate\Engine();
echo $engine->render("sample.my", ['xxx' => 'yyy']);

MyTemplate\Engine cache compiled template by default. If you don't want to cache, you can specify NULL to constructor argument.

new \MyTemplate\Engine(null);

The cache directory is cache by default. If you change cache directory, you can specify string directory path to constructor argument.

new \MyTemplate\Engine('/tmp');

Template Syntax

output variable

{{ foo }}

if statement

{{ if xxx }}
<div>hello</div>
{{ else }}
<div>world</div>
{{ end }}

for statement

{{ for var : vars }}
<li>{{ var }}</li>
{{ end }}

include other template

{{ include 'other.my' }}

lookup getter property

{{ foo.bar }}

This is compiled to

$foo->getBar();

So foo variable should be implemented public getBar() method.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages