Is there a reason we don't automatically wrap JavaScript expressions
with a CDATA tag in the tag compiler? ACurrently, LZX JavaScript
expressions have to look like this:
<method name="foo">
if (narg < 1 && bar == foo) blarg;
</method>
Adding a CDATA tag makes for much more readable source:
<method name="bar"><![CDATA[
if (narg < 1 && bar == foo) blarg;
]]></method>
Both of these methods currently end up compiling to:
if (narg < 1 && bar == foo) blarg;
We could add the CDATA tag automatically if it's missing. Adding
missing CDATA tags in LZX has a huge quality of life benefit of escaping
< and & in LZX methods.
Making this change would also resolve encoding issues, like
http://jira.openlaszlo.org/jira/browse/LPP-1948. This bug shows a
difference in swf and DHTML rendering would be fixed with this change.
Here's some simplified LZX from the bug report:
<canvas>
<method name="foo">
canvas.boo.setText('herring < bobby');
</method>
<method name="bar"><![CDATA[
canvas.boo.setText('herring < bobby');
]]></method>
</canvas>
Running 'lzc -runtime=swf7 --script' produces this javascript
(simplified again):
#file cdata_text_testcase.lzx
#line 6
canvas.boo.setText('herring < bobby');
#endContent
...
#file cdata_text_testcase.lzx
#line 2
canvas.boo.setText('herring < bobby');
#endContent
Wrapping expressions in CDATA tags if they don't already have one It
seems like a fairly straightforward XML transformation. What are your
thoughts?
--
Regards,
Max Carlson
OpenLaszlo.org