Skip to content

ramonszo/t.php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

t.php

A tiny php templating framework based on t.js

t.php is a simple solution to interpolating values in an html string.

Features

  • Simple interpolation: {{=value}}
  • Scrubbed interpolation: {{%unsafe_value}}
  • Name-spaced variables: {{=User.address.city}}
  • If/else blocks: {{value}} <<markup>> {{:value}} <<alternate markup>> {{/value}}
  • If not blocks: {{!value}} <<markup>> {{/!value}}
  • Object/Array iteration: {{@object_value}} {{=_key}}:{{=_val}} {{/@object_value}}
  • Multi-line templates (no removal of newlines required to render)
  • Render the same template multiple times with different data

How to use

$template = new T("<div>Hello {{=name}}</div>");
echo $template->parse(array('name' => 'World!'));

For more advanced usage check the t_test.php.

This software is released under the MIT license.

Alternatives

Javascript version maintained by @jasonmoo


About

A tiny php templating framework based on t.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%