Discussion:
Disable Dollar Sign Prefix Genshi Variable
jerry
2012-03-15 13:06:56 UTC
Permalink
Hi,

Is there a way to disable simple dollar sign prefixed variable
interpretation in Genshi XML template, such as $var? (i.e., leave only
the more canonical ones ${var})

This is because $var format conflicts with variables widely used in
JavaScript (especially JQuery).

Thanks.

Jerry
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.
Łukasz Michalski
2012-03-15 16:44:39 UTC
Permalink
Post by jerry
Hi,
Is there a way to disable simple dollar sign prefixed variable
interpretation in Genshi XML template, such as $var? (i.e., leave only
the more canonical ones ${var})
This is because $var format conflicts with variables widely used in
JavaScript (especially JQuery).
Hi Jerry,

I use CDATA in my scripts. Genshi does not touch anything inside CDATA
block.

Regards,
Łukasz
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.
jerry
2012-03-16 05:35:21 UTC
Permalink
Well, it doesn't work for me --

In [1]: import genshi

In [2]: genshi.__version__
Out[2]: '0.6'

In [3]: from genshi.template import MarkupTemplate

In [4]: tmpl_str = """<html>
...: <head>
...: <script type="text/javascript">
...: /*<![CDATA[*/
...: var $dollar = 'Dollar';
...: /*]]>*/
...: </script>
...: </head>
...: <body></body>
...: </html>"""

In [3]: tmpl = MarkupTemplate(tmpl_str)

In [4]: print tmpl.generate().render('xhtml')
---------------------------------------------------------------------------
UndefinedError Traceback (most recent call
last)
/home/jerryj/hg/pweb/<ipython-input-4-93875b202eeb> in <module>()
----> 1 print tmpl.generate().render('xhtml')

...

UndefinedError: "dollar" not defined


Jerry
Post by Łukasz Michalski
Post by jerry
Hi,
Is there a way to disable simple dollar sign prefixed variable
interpretation in Genshi XML template, such as $var? (i.e., leave only
the more canonical ones ${var})
This is because $var format conflicts with variables widely used in
JavaScript (especially JQuery).
Hi Jerry,
I use CDATA in my scripts. Genshi does not touch anything inside CDATA
block.
Regards,
Łukasz
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to genshi+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/genshi?hl=en.
Loading...