Download the PHP package bonfim/tpl without Composer
On this page you can find all versions of the php package bonfim/tpl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package tpl
Short Description Sketch is an PHP template engine and provide a better way to produce dynamic web pages.
License MIT
Homepage https://github.com/EdsonOnildoJR/Sketch
Informations about the package tpl
PHP-Template-Engine
Table of Contents
- Prerequisites
- Installation
- Basic Usage
- Sketch Tags
- Variables
- Conditional Expression
- Loop
- Function
- Include
- Contributing
- Security
- Credits
- License
Prerequisites
- PHP 7.1+
Installation
Basic usage
Create an index.php file and require the autoload.php of composer
After that, let's to do all necessary configuration
Assign and render template
Sketch Tags
- Variables
- Conditional Expression
- Loop
- Function
- Include
Variables
Variables are the dynamic content of the template, valorized on the execution of the script with Tpl::assing() static method. Variables names are case sensitive.
Template:
Data:
Output:
Modifiers on variables
You can add modifiers that are executed on the variables.
Template:
Data:
Output:
Conditional Expression
Checks an expression and print the code between {if}{else} if the conditions is true or {else}{/if} if the condition is false. Try to use nested blocks :)
Template:
Data:
Output:
you can also use the {if condition}content{elseif condition}content{else}content{/if} or any combination of if and else.
Loop
Allow to loop through the value of arrays or objects.
Template:
Data:
Output:
Function
Use {func funcname()} tag to execute a PHP function and print the result. You can pass strings, numbers and variables as parameters.
Template:
Output:
Include
With {include 'template'} tag you can include external template as blocks.
Template:
Output:
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Edson Onildo
- All Contributors
License
The MIT License (MIT). Please see License File for more information.