syrusakbary / pyjade

Jade template system for Django, Jinja2 and Mako
MIT License
698 stars 124 forks source link

a(href=url index) ? #207

Open gummz opened 9 years ago

gummz commented 9 years ago

The reason why I love PyJade so much is that I can for example do - load crispy_forms instead of {% load crispy_forms %}. But how would I do this for

a(href="{% url 'index' %") ? Can I do that?

blx commented 9 years ago

Yup, just like that should work!

I'm using pyjade with django and have lots of elements using django tags:

link(rel="stylesheet", href="{% static 'x.css' %}")
form(action="{% url 'buy:pay' %}")

etc.

eskhool commented 9 years ago

I believe the OP wanted to not have to use the {% delimiters that django template engine and use the jade syntax instead. Your examples don't answer that, I think.

blx commented 9 years ago

Good point. But I don't believe there's a direct translation.

- load crispy_forms works because it's a line statement in pyjade, but without some kind of delimiter pyjade can't parse it (at present) when it's mixed into a tag's attributes or so on.

What would be the expected/desired/intuitive jade syntax for this?

a(href=url("index"))
a(href="- url 'index'")

?

eskhool commented 9 years ago

Ideally a(href=url("index")) just because it looks right and fits with jade

zhaolixiao commented 7 years ago

I tried a lot times, finally figure it out:

html code: <a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a> then Jade code should be: a(href!='{% url 'polls:detail' question.id %}')= question.question_text

and if the 'detail' link don't need paramater, it should be like this: a(href!='{% url 'polls:detail' %}')