pyjade icon indicating copy to clipboard operation
pyjade copied to clipboard

Double quotes in attribute

Open aspicer opened this issue 11 years ago • 4 comments

In its current form, pyjade converts

div(ng-hide='status == "Live"')

into

<div ng-hide="status == "Live"")

This seems like incorrect behavior, since it returns incorrect html.

It seems like this can be fixed by changing line 124 of nodes.py to something like:

return ("'%s'" if '"' in string else '"%s"') % string

or by escaping attributes. Normal jade turns such an attribute into:

<div ng-hide="status=&quot;Live&quot;"

Let me know if I'm missing something or if this seems like a worthwhile fix.

Thanks!

aspicer avatar Dec 10 '13 11:12 aspicer

You are right, just changing the behavior for printing the same quotes that appear should solve this bug.

syrusakbary avatar Dec 10 '13 20:12 syrusakbary

You can also do something like this

div(ng-hide="status == 'Live'")

syrusakbary avatar Dec 10 '13 20:12 syrusakbary

This bug is a problem when sharing the same jade files bw a JS project and python project (and JS is the main source) e.g for buildbot custom_template_dir: http://docs.buildbot.net/latest/manual/cfg-www.html#web-server

How is it difficult to fix?

tardyp avatar Nov 03 '16 13:11 tardyp

+1 for fixing it

Frodox avatar Nov 03 '16 14:11 Frodox