PHP Classes

File: docs/Features/Including pre-processed templates.md

Recommend this page to a friend!
  Packages of Rafa Rodriguez   Div PHP Template Engine   docs/Features/Including pre-processed templates.md   Download  
File: docs/Features/Including pre-processed templates.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: Div PHP Template Engine
Template processing engine that replaces tags
Author: By
Last change:
Date: 3 months ago
Size: 607 bytes
 

Contents

Class file image Download

Similar to [[Including another templates]], but in this case, first the engine parse the template, and then include it.

Syntax in templates


{%% var with path to the template's part %%}
	
OR
	
{%% path/to/the/template/part %%}

Example

index.php

<?php
	
echo new div('test.tpl', [
	'name' => 'Unnamed',
	'products' => [
		['name' => 'Banana'],
		['name' => 'Potato']
	]
]);

index.tpl

	
Include:
	
[$products]
	{% part %}
[/$products]
	
Preprocessed:
	
[$products]
	{%% part %%}
[/$products]

part.tpl


{$name}

Output


Banana
	
Potato
	
Unnamed
	
Unnamed