pdyn/template

A fast, simple Html template library with support for conditionals, loops, and includes.

1.0.6 2016-06-13 21:49 UTC

This package is auto-updated.

Last update: 2020-08-09 23:46:54 UTC


README

A fast, simple Html template library with support for conditionals, loops, and includes.

Usage:

In your PHP:

Initialize the template class.

$template = new \pdyn\template\HtmlTemplate([[template directory]]);

Assign template files to the class, and give each an alias.

$template->file(['[[template file alias]]' => '[[template filename]]');

Assign global variables.

$template->assign_var($key, $value);

Assign sections.

$template->assign_sect($name, [$key => $value, $key2 => $value2]);

Display the template.

echo $template->display('[[template file alias]]');

In your template files:

Template files are simple HTML files with special tokens.

Global variables

Global variables are accessed like {key}. These will be replaced with the value you set using ->assign_var().

Sections

Sections serve as both conditionals and loops, depending on how many times you assigned them using ->assign_sect().

To start a section, use