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 #3652

Templates eat expressions in variable values that are enclosed in braces.

Details

Submitted2005-03-01 01:54 UTC
Fromsullivan at mathcs dot wilkes dot edu
Assignedpajoye
StatusBogus
PackageHTML_Template_IT
PHP Version4.3.10
OSLinux (Gentoo)
Roadmaps(Not assigned)

Comments

[2005-03-01 01:54 UTC] sullivan at mathcs dot wilkes dot edu

Description:
------------
If a template variable is assigned a value containing a substring enclosed in braces, that substring is eaten when the template is rendered.

This bug arose in a program that attempts to display php
source files and templates in a nice way, using templates.
The strings in question arose because the contents of the template files were assigned as the values of template variables in the viewing program.

Reproduce code:
---------------
foo.php:
--------
<?php

require_once "HTML/Template/IT.php";

$template = new HTML_Template_IT(".");
$template->loadTemplatefile("foo.tpl", true, true);
$template->setCurrentBlock("FOO");
$template->setVariable("FOO", "This is a {FOOBAR} foo!");
$template->parseCurrentBlock();
$template->show();

?>
------------------

foo.tpl:
--------
<html>
<body>

This is a foo!

</body>
</html>
-------

Expected result:
----------------
<html>
<body>

This is a {FOOBAR} foo!

</body>
</html>

Actual result:
--------------
<html>
<body>

This is a foo!

</body>
</html>

Note that the substring {FOOBAR} of the variable value
is replaced by a space.

[2005-03-01 01:58 UTC] sullivan at mathcs dot wilkes dot edu

Oops. The foo.tpl file should have been:

<html>
<body>
<!-- BEGIN FOO -->
{FOO}
<!-- END FOO -->
</body>
</html>

[2005-03-03 11:13 UTC] pierre at dotgeek dot org

The default does not preserve variables in the results.

To change the default the default behiavior, see setOptions, or pass the option to the constructor:

array('preserve_data'=>true)

--Pierre