PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_Template_IT » Bug #8255

Outer variables parse problem after parsing nested

Details

Submitted2006-07-20 09:21 UTC
Fromgvre at gvre dot gr
Assigneddsp
StatusBogus
PackageHTML_Template_IT
PHP Version5.1.4
OSSlackware Linux
Roadmaps(Not assigned)

Comments

[2006-07-20 09:21 UTC] gvre at gvre dot gr

Description:
------------
Hello,

It seems that IT doesn't parse outer variables after parsing inner (nested) variables.

Test script:
---------------
<!-- test.tpl.html -->
<!-- BEGIN main -->
<input type="text" value="{ANS_{LANG_ID}_0}" />
<!-- END main -->

<?php

require_once("HTML/Template/IT.php");

$tpl = & new HTML_Template_IT(".");

$tpl->loadTemplatefile("test.tpl.html", false, true);
$tpl->setCurrentBlock("main");
$tpl->setVariable("LANG_ID", 1);
$tpl->setVariable("ANS_1_0", "test");
$tpl->parseCurrentBlock();
$tpl->show();

?>

Expected result:
----------------
<input type="text" value="test" />

Actual result:
--------------
<input type="text" value="{ANS_1_0}" />

[2006-07-20 10:20 UTC] dsp at php dot net

Thank you for taking the time to write to us, but this is not
a bug.

Hello,
thanks for the report.

IT aims to be fast and without too much complexity. Thus ITX doesn't support nested placeholders, sorry.

If you really need such a behaviour, suggest to use workarounds like that:

Test Script:
------
<!-- BEGIN main -->
<input type="text" value="{ANS_{LANG_ID}_0}"
/>
<!-- END main -->
{newblock}

<?php

require_once("HTML/Template/ITX.php");

$tpl = & new HTML_Template_ITX(".");

$tpl->loadTemplatefile("test.tpl.htm", false, true);
$tpl->setCurrentBlock("main");
$tpl->setVariable("LANG_ID", 1);
$tpl->parse("main");
$tpl->addBlock("newblock","mynewblock",$tpl->get("main")));
$tpl->setCurrentBlock("mynewblock");
$tpl->setVariable("ANS_1_0", "test");
$tpl->parseCurrentBlock();
$tpl->show();

?>