[PHPTAL] How To Prevent HTML escaping

Joshua Paine lists at fairsky.us
Sat Apr 15 01:59:37 CEST 2006


Bill Van Vooren wrote:
> "<div tal:content="structure my/safe/string"></div>"
> works great, and "structure textile:" is very
> interesting.  

"structure" is a keyword that you can use to indicate that the path that 
follows should be used as-is without escaping.

"textile:" is a custom modifier that you have to create to make it work. 
See <http://phptal.motion-twin.com/manual/en/#id2500659>. As an example, 
I personally prefer Markdown to Textile (same kind of thing), so I have 
the following:

function do_markdown($var)
{
	require_once('markdown.php');
	require_once('smartypants.php');
	return SmartyPants(Markdown($var));
}

function phptal_tales_markdown($src, $nothrow)
{
	return 'do_markdown('.phptal_tales_path(trim($src), $nothrow).')';
}

The naming convention "phptal_tales_foo" is magic--it makes the "foo:" 
modifier available to TAL documents. So long as both of those are 
defined, I can write:

<div tal:content="structure markdown:some/path"></div>

-- 
Joshua Paine
Chief Tower Builder
LetterBlock Software
http://letterblock.com/



More information about the PHPTAL mailing list