davidtingsu / html2hamlpy

convert HTML to HamlPy
https://pypi.python.org/pypi/html2hamlpy
MIT License
2 stars 2 forks source link

Html2Hamlpy fails if the html contains templatetags #3

Open Psycojoker opened 9 years ago

Psycojoker commented 9 years ago

Hello,

As demonstrated in the following example, html2hamlpy doesn't support django templatetags syntaxe included directly into an html tag:

In [7]: print Converter('<script type="text/javascript" src="{% static \'resumable/js/django-resumable.js\' %}"></script>', 'html.parser').to_haml()
%script{src:"<dynamic dynamic=", 'resumable:"", js:"", static:"", django-resumable.js'":"", type:"text/javascript"}
">

The expected result is:

%script{src:"{% static 'resumable/js/django-resumable.js' %}", type:"text/javascript"}

Cheers,

davidtingsu commented 9 years ago

Thanks, I will get to this when I get the chance.

Psycojoker commented 9 years ago

Also, to warn you from my experience of doing this manually, there is some html code that you can't convert to haml directly, for exemple:

<tag {% if condition %}foo="bar"{% endif %}>...

Is not convertible into haml AFAIK.