PHP Classes

Puja: Template engine that compiles templates into PHP

Recommend this page to a friend!
  Info   View files View files (35)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 414 All time: 6,452 This week: 560Up
Version License PHP version Categories
puja 1.0BSD License5.0PHP 5, Cache, Templates, Code Generation
Description 

Author

This package is a template engine that compiles templates into PHP.

It can validate and compile a template file. The template syntax allows conditional sections that can be nested.

It can compile a given template file and generate a PHP script with code that generates the output taking the template parameters and replacing them in the respective template mark positions.

The output of the compiled templates is stored in cache files to prevent recompilation time overhead. It can recompile template files only if they changed.

It supports a debug mode to provide more information when template processing fails due to a syntax error or some other reason.

Picture of Jin Nguyen
  Performance   Level  
Name: Jin Nguyen <contact>
Classes: 1 package by
Country: Viet Nam Viet Nam
Age: 40
All time rank: 350116 in Viet Nam Viet Nam
Week rank: 4338 Down30 in Viet Nam Viet Nam Down

Recommendations

What is the best PHP landing page creation class?
Create new PHP landing pages on the fly

Details

Puja

Puja is a lightweight, flexible and easy PHP template engine. Inspired in django, Puja also support validate template syntax!

<strong>Some of Puja's features</strong>: * <strong>VALIDATE TEMPLATE SYNTAX</strong> * it is extremely fast * no template parsing overhead, only compiles once. * it is smart about recompiling only the template files that have changed. * unlimited nesting of sections, conditionals, etc. * built-in caching of template output.

<strong>Validate syntax:</strong><br /> Puja support validate syntax before the parser run compiler. This will helpfull for you to write template syntax.

Example: file template: index.tpl: <pre> Hello {{ username }, Welcome you go to the very first exmplate of Puja template.</pre>

The result will be: <pre> TemplateSyntaxError: <strong>missing }}</strong> 1. Hello <strong>{{ username </strong>, 2. Welcome you go to the very first exmplate of Puja template.</pre>

Puja only show debug when mode <strong>debug</strong> is enabled<br /> We recommend you should only enable mode <strong>debug</strong> when your app is in develop. And disable it when your app go to production. It will save a lot time to template engine parser. <br /><br /> <strong>Basic API Usage</strong>:<br /> - template file: index.tpl <pre>Hello <strong>{{ username }}</strong>, Welcome you go to the very first exmplate of Puja template.</pre>

  • php file: index.php <pre> &lt;?php require_once '/path/to/puja.php'; $tpl = new Puja; $tpl->tpl_dir = '/path/to/template/folder/'; $data = array( 'username'=>'Jin Nguyen', ); $tpl->parse($template_file = 'index.tpl', $data); ?&gt; </pre>

The result will show: <pre> Hello <strong>Jin Nguyen</strong>, Welcome you go to the very first exmplate of Puja template.</pre>

See <a href="https://github.com/jinnguyen/puja/tree/master/docs/user-guide.md">User's guide</a> for full information.<br />

<strong>Template Inheritance</strong>:<br /> - master.tpl: <pre>==== Start Master === {% block body %}Master Body{% endblock body %} {% block javascript %}Master javascript{% endblock javascript %} ==== End Master ====</pre>

  • index.tpl <pre> {% block javascript %}<strong>Index javascript</strong>{% endblock javascript %} {% block body %}<strong>Index Body</strong>{% endblock body %}</pre>

And the result will be:

<pre>==== Start Master === <strong>Index Body</strong> <strong>Index javascript</strong> ==== End Master ====</pre> <a href="https://github.com/jinnguyen/puja/tree/master/docs">more detail &gt;&gt; </a>

githalytics.com alpha


  Files folder image Files  
File Role Description
Files folder imagedocs (6 files)
Files folder imageexamples (8 files, 1 directory)
Files folder imagesrc (6 files)
Accessible without login Plain text file .buildpath Data Auxiliary data
Accessible without login Plain text file .project Data Auxiliary data
Accessible without login Plain text file LICENSE Doc. Documentation
Plain text file puja.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  docs  
File Role Description
  Accessible without login Plain text file built-in-filters.md Doc. Documentation
  Accessible without login Plain text file built-in-tags.md Doc. Documentation
  Accessible without login Plain text file coding-standards.md Doc. Documentation
  Accessible without login Plain text file custom-template-tags.md Data Auxiliary data
  Accessible without login Plain text file README.md Doc. Documentation
  Accessible without login Plain text file user-guide.md Data Auxiliary data

  Files folder image Files  /  examples  
File Role Description
Files folder imagetemplates (10 files)
  Accessible without login Plain text file build_compress.php Example Example script
  Accessible without login Plain text file custom.php Example Example script
  Accessible without login Plain text file filter.php Example Example script
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file phpinfo.php Example Example script
  Accessible without login Plain text file structure.php Example Example script
  Accessible without login Plain text file subtemplate.php Example Example script
  Accessible without login Plain text file variable.php Example Example script

  Files folder image Files  /  examples  /  templates  
File Role Description
  Accessible without login Plain text file build_compress.tpl Data Auxiliary data
  Accessible without login Plain text file custom.tpl Data Auxiliary data
  Accessible without login Plain text file filter.tpl Data Auxiliary data
  Accessible without login Plain text file include.tpl Data Auxiliary data
  Accessible without login Plain text file index.tpl Data Auxiliary data
  Accessible without login Plain text file jquery-1.3.2.min.js Data Auxiliary data
  Accessible without login Plain text file master.tpl Data Auxiliary data
  Accessible without login Plain text file structure.tpl Data Auxiliary data
  Accessible without login Plain text file subtemplate.tpl Data Auxiliary data
  Accessible without login Plain text file variable.tpl Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file cache.php Class Class source
  Plain text file compiler.php Class Class source
  Accessible without login HTML file debug.html Data Auxiliary data
  Plain text file debug.php Class Class source
  Plain text file filter.php Class Class source
  Plain text file tags.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:414
This week:0
All time:6,452
This week:560Up