|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
juanjico Smarty n00b
Joined: 03 Aug 2015 Posts: 1
|
Posted: Mon Aug 03, 2015 7:30 pm Post subject: Can't create an XML with javscript inside using smarty |
|
|
Hi!
I have this template:
Code: | <?xml version="1.0" encoding="utf-8"?>
<item>
<Description><![CDATA[{$description}]]></Description>
</item> |
$description contains HTML code with Javascript and CSS. Note the CDATA block in the XML to avoid parse that code.
Code: | $description = '
<p>This is just a test</p>
<script type="text/javascript">
alert('a');
</script> |
When I assign the variable to the template and parse it, this is the result:
Code: | <?xml version="1.0" encoding="utf-8"?>
<item>
<Description><![CDATA[<p>This is just a test</p>
<script type="text/javascript">/* <![CDATA[ */;alert('a');/* ]]> */</script> ]]></Description>
</item>
|
For some reason, smarty is adding a new CDATA to the javascript code, but taking in care that is to be used in XML, this is ilegal because two CDATA can't be nested. This XML don't validate.
Is there a way to avoid smarty add the CDATA and leave the javascript code intact ?
Thanks! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Aug 03, 2015 9:26 pm Post subject: |
|
|
Smarty itself does not add anything to the output.
I suspect that it's already in the $description variable var_dump() it or set
$smarty->debugging = true; to check the assigned values of all template variables.
or
Did you enable some default modifier?
Check if {$description nofilter} will change anything.
or
Have you loaded an output filter which may do it.
Note: when you modify default modifier or filter settings you must force a recompile manually.
Best is to disable caching and set $smarty->force_compile = true while experimenting. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|