Stud.IP  6.0
PhpTemplate Class Reference
Inheritance diagram for PhpTemplate:
Template

Public Member Functions

 render_partial (Template|string $partial, array $attributes=[])
 
 render_partial_collection (string $partial, array $collection, Template|string|null $spacer=null, array $attributes=[])
 
- Public Member Functions inherited from Template
 __construct (protected string $template, protected Factory $factory, protected array $options=[])
 
 __set (string $name, mixed $value)
 
 __get (string $name)
 
 __isset (string $name)
 
 __unset (string $name)
 
 render (array $attributes=[], string|Template $layout=null)
 
 get_attribute (string $name)
 
 get_attributes ()
 
 set_attribute (string $name, mixed $value)
 
 set_attributes (array $attributes)
 
 clear_attributes ()
 
 clear_attribute (string $name)
 
 set_layout (Template|string|null $layout)
 
 get_layout ()
 

Protected Member Functions

 _render ()
 
- Protected Member Functions inherited from Template
 _render ()
 

Additional Inherited Members

- Protected Attributes inherited from Template
array $attributes = []
 
Template null $layout = null
 

Member Function Documentation

◆ _render()

_render ( )
protected

Parse, render and return the presentation.

Returns
string A string representing the rendered presentation.
Exceptions
TemplateNotFoundException

◆ render_partial()

render_partial ( Template|string  $partial,
array  $attributes = [] 
)

Parse, render and return the presentation of a partial template.

Parameters
Template | string$partialA partial name or template
array$attributesAn optional associative array of attributes and their associated values.
Returns
string A string representing the rendered presentation.
Exceptions
TemplateNotFoundException

◆ render_partial_collection()

render_partial_collection ( string  $partial,
array  $collection,
Template|string|null  $spacer = null,
array  $attributes = [] 
)

Renders a partial template with every member of a collection. This member can be accessed by a template variable with the same name as the name of the partial template.

Example:

template entry.php contains:

<?= $entry ?>

$entries = ['lorem', 'ipsum']; $template->render_partial_collection('entry', $entries);

results in:

lorem ipsum

If you want to use specific content between the rendered partials, you may define a spacer partial that will be used for that. The spacer will be rendered with the given attributes.

Parameters
string$partialA name of a partial template.
array$collectionThe collection to be rendered.
Template | string | null$spacerOptional a name of a partial template used as spacer.
array$attributesAn optional associative array of attributes and their associated values.
Returns
string A string representing the rendered presentation.
Exceptions
TemplateNotFoundException

The documentation for this class was generated from the following file: