RainTPL is an open source PHP template engine, it load precompiled PHP templates:
Downloadhow RainTPL copy, the file rain.tpl.class.php in your project include directory inc/, create a templates directory tpl/, and a cache directory tmp/.
Here the tags you need
Variables are the dynamic contents of the templates, you can assign them with assign() method. Variables are case_sensitive.
You can do simple operations such as + - * / % with numbers, string and other variables and also use = for assign a value to a variable
You can use functions with variables
Use {$GLOBALS} to access all globals variable as _SESSION, _GET, _POST, _SERVER.
You can constants with this syntax: {#constant#}
Is the equivalent of php if. You can use variable and php into the condition.
This tag allow you to loop an array, it's useful to print a list of articles, news.
Betweein {loop} and {/loop} you can use special variables:
Use this tag for include external templates. Useful for include header and footer if they are the same in all page of your website.
You can also use use static cache with include tag. Check the documentation.
Call php functions and print the result.
All between {* and *} is deleted in the compiled file. Use this tag to comment your templates.
All the code between {noparse} {/noparse} it won't be parsed
Output:
This cool feature allows designers to create templates as regular HTML with images and styles with relative paths, RainTPL replaces automatically these paths with the correct server paths.
Absolute paths and paths ending with # will be not changed.
Output html:
Note: if you set raintpl::$base_url, RainTPL will replace the path with raintpl::$base_url.
This is what you've to write in your script to assign variables and draw the template.
Is avalaible also a Cache method which can improve drastically the load speed of your page. Check the documentation.