php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20199 HTML_Template_IT Logic Error
Submitted: 2002-10-31 13:46 UTC Modified: 2002-11-15 19:06 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: adam at tux dot appstate dot edu Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.2.3 OS: Red Hat 8.0
Private report: No CVE-ID: None
 [2002-10-31 13:46 UTC] adam at tux dot appstate dot edu
When assigning a string that contains a "replacement variable"-like sub-string to an actual replacement variable, on IT's next "pass" it will replace the variable-like sub-string with nothing and if this string was contained within a block it will remove the block:

Example
Lets assume for some unknown reason the programmer wishes to print name like this -> {name}

<code>
<?php

require_once("HTML/IT.php");

$vars["title"] = "Welcome! {Adam}";
$vars["content"] = "This is some content!";

$template = "
<!-- BEGIN TITLE -->
{title}<br />
<!-- END TITLE -->
<!-- BEGIN CONTENT -->
{content}<br />
<!-- END CONTENT -->";

$tpl = new HTML_Template_IT;
$tpl->setTemplate($template, TRUE, TRUE);
$tpl->setVariable($vars);

echo $tpl->get();

?>
</code>

When the above template and data is processed by IT it will not print the name contained in the string $vars["title"].

I hope this is enough info to figure out what's up :)

Adam

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-15 19:06 UTC] pajoye@php.net
This is normal. Try this:

$tpl = new HTML_Template_IT();
$tpl->setTemplate($template, TRUE, TRUE);
$tpl->removeUnknownVariables = false;
$tpl->setVariable($vars);
$tpl->show();

thanks for the report

hth

pa
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC