Skip to content

02.38 Multiple dialects

rafageist edited this page Nov 16, 2026 · 1 revision

2.38 Múltiples dialectos

Puedes fijar un dialecto por plantilla con la propiedad @_DIALECT. El archivo de dialecto contiene un objeto JSON con redefiniciones de DIV_TAG_*.

Ejemplo

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
    ]
]);

Salida

Name: Peter

{$name}

45

Div

Enlaces

Clone this wiki locally