2017 © Pedro Peláez
 

library sketch

Sketch is an PHP template engine and provide a better way to produce dynamic web pages.

image

sketchphp/sketch

Sketch is an PHP template engine and provide a better way to produce dynamic web pages.

  • Tuesday, May 1, 2018
  • by EdsonOnildo
  • Repository
  • 0 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

PHP-Template-Engine

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Table of Contents

Prerequisites

  • PHP 7.1+

Installation

``` bash $ composer require EdsonOnildoJR/PHP-Template-Engine, (*2)


Basic usage ----------- Create an **index.php** file and require the autoload.php of composer ``` php <?php include 'vendor/autoload.php';

After that, let's to do all necessary configuration, (*3)

``` php use Sketch\Tpl;, (*4)

Tpl::config([ //'environment' => 'production', 'environment' => 'development', 'template_dir' => 'path/to/templates', 'cache_dir' => 'path/to/caches' ]);, (*5)


Assign and render template ``` php Tpl::assing('title', 'Hello!'); Tpl::render('test');

Sketch Tags

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., (*6)

Template: ``` html Welcome to {title}, (*7)


**Data:** ``` php <?php Tpl::assign('title', 'Sketch');

Output: ``` html Welcome to Sketch, (*8)


### Modifiers on variables You can add modifiers that are executed on the variables. **Template:** ``` html Hello {name|capitalize}!

Data: ``` php <?php, (*9)

Tpl::assign('name', 'edson onildo');, (*10)


**Output:** ``` html Hello Edson Onildo!

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 :), (*11)

Template: ``` html {if age >= 18} Adult {else} Minor {/if}, (*12)


**Data:** ``` php <?php Tpl::assign('age', 19);

Output: ``` html Adult, (*13)


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:** ``` html <ul> {loop authors as author} <li> {author.name}: {author.page} </li> {/loop} </ul>

Data: ``` php <?php, (*14)

$authors = [ [ 'name' => 'Edson Onildo', 'page' => 'https://github.com/EdsonOnildoJR' ], [ 'name' => 'Contributors', 'page' => 'https://github.com/EdsonOnildoJR/Sketch/contributors' ] ];, (*15)

Tpl::assign('authors', $authors);, (*16)


**Output:** ``` html Edson Onildo: https://github.com/EdsonOnildoJR Contributors: https://github.com/EdsonOnildoJR/Sketch/contributors

Function

Use {func funcname()} tag to execute a PHP function and print the result. You can pass strings, numbers and variables as parameters., (*17)

Template: ``` html {func date('Y')}, (*18)


**Output:** ``` html 2018

Include

With {include 'template'} tag you can include external template as blocks., (*19)

Template: ``` html , (*20)

New user:

{template 'userForm'}

**Output:** ``` html <h1>New user:</h1> <form class="user" action="" method="post"> ... </form>

Change log

Please see CHANGELOG for more information on what has changed recently., (*21)

Testing

bash $ composer test, (*22)

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*23)

Security

If you discover any security related issues, please email inbox.edsononildo@gmail.com instead of using the issue tracker., (*24)

Credits

License

The MIT License (MIT). Please see License File for more information., (*25)

The Versions

01/05 2018

dev-master

9999999-dev https://github.com/EdsonOnildoJR/Sketch

Sketch is an PHP template engine and provide a better way to produce dynamic web pages.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

29/04 2018

v2.0.2

2.0.2.0 https://github.com/EdsonOnildoJR/Sketch

Sketch is an PHP template engine and provide a better way to produce dynamic web pages.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

29/04 2018

v2.1.0

2.1.0.0 https://github.com/EdsonOnildoJR/Sketch

Sketch is an PHP template engine and provide a better way to produce dynamic web pages.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

04/04 2018

v2.0.1

2.0.1.0 https://github.com/EdsonOnildoJR/Sketch

Sketch is an PHP template engine and provide a better way to produce dynamic web pages.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

04/04 2018

v2.0.0

2.0.0.0 https://github.com/EdsonOnildoJR/Sketch

Sketch is an PHP template engine and provide a better way to produce dynamic web pages.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

29/03 2018

v1.0.1

1.0.1.0 https://github.com/EdsonOnildoJR/BonfimTPL

BonfimTPL is an PHP template engine and provide a better way to produce dynamic web pages.

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

template php view template engine tpl bonfimtpl

10/03 2018

v0.1-alpha

0.1.0.0-alpha https://github.com/BonfimSystems/view

Bonfim View Component

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

template php view tpl bonfim bonfimsystems

10/03 2018

v1.0.0

1.0.0.0 https://github.com/BonfimSystems/view

Bonfim View Component

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

template php view tpl bonfim bonfimsystems