PHP Classes

File: docs/Features/Multiple dialects.md

Recommend this page to a friend!
  Packages of Rafa Rodriguez   Div PHP Template Engine   docs/Features/Multiple dialects.md   Download  
File: docs/Features/Multiple dialects.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: 941 bytes
 

Contents

Class file image Download

With the template's property @__DIALECT you can specify the dialect for current template source. This dialect should be written in a separeted file with JSON code. For example:

Example

index.tpl

@_DIALECT = smarty.dialect
{this is a comment}
Name: {$name}
{literal}
{$name}
{/literal}
{% other %}

other.tpl

@_DIALECT = twig.dialect
{{ foo.bar }}

smarty.dialect

{
  'DIV_TAG_IGNORE_BEGIN': '{literal}',
  'DIV_TAG_IGNORE_END': '{/literal}',
  'DIV_TAG_COMMENT_BEGIN': '{*',
  'DIV_TAG_COMMENT_END': '*}'
}

twig.dialect

{
  'DIV_TAG_REPLACEMENT_SUFFIX': ' }}',
  'DIV_TAG_MODIFIER_SIMPLE': '{ '
}

index.php

<?php
	
include "div.php";
	
echo  new div("index.tpl", [
	'name' => 'Peter',
	'foo' => [
		'bar' => 45
	]
]);

Output

Name: Peter
	
{$name}
	
45