Download the PHP package tuum/view without Composer
On this page you can find all versions of the php package tuum/view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package view
Short Description raw PHP template renderer that does not escape.
License MIT
Informations about the package view
View Template
A raw PHP based template with sections, block, and layout, but no escaping functions.
To escape values displayed in a template, use other packages, such as Tuum/Form.
Licence
MIT Licence
PSR
PSR-1, PSR-2, and PSR-4.
Getting Started
Installation
Sample Code
Constructing the renderer:
To render a PHP template file,
The template file at /path/to/view/my/file-name.php
may be:
The Tuum/View does not escape the value. Please use helpers to escape before displaying the values.
Using Layout
You can set a default layout in the renderer:
or set layout inside individual template file (hence overwrites the default layout):
layout file
In a layout file, emit content (from the initial template file) using method.
Using Section
in template file
In a template file, define a section using
and ,
in layout file
In a layout file, use the defined section as:
You can check if a section is defined:
replaceBy method
Using in layout file may make it clearer...
method will take the output from a section (from till method) and checks if the named section exists or not. If the section exists, it outputs the existing section, or outputs the section in the layout.
disabling a section in layout
In the template file, it is possible to set a section not to be displayed at all by using method.
In template file:
In layout file:
Because the section is marked as NotToRender, the entire bread section will not be rendered.
This also works for as well. So, for the example for will not be displayed at all if marked as NoDisplay.
Using Block
To include another template, use method in a template file as:
The is another template file. The template's data is shared with the block template.
blockAsSection method
Some times, one might want to use a block as a section (well, I do). So, here's an easy way to do.