Disable Dollar Sign Prefix Genshi Variable

63 views
Skip to first unread message

jerry

unread,
Mar 15, 2012, 9:06:56 AM3/15/12
to Genshi
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

Łukasz Michalski

unread,
Mar 15, 2012, 12:44:39 PM3/15/12
to gen...@googlegroups.com
W dniu 2012-03-15 14:06, jerry pisze:

Hi Jerry,

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

Regards,
Łukasz

jerry

unread,
Mar 16, 2012, 1:35:21 AM3/16/12
to Genshi
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
Reply all
Reply to author
Forward
0 new messages