I'm trying to do something like this in my jade template
a.apply-url(href="#{apply-url}")
But it's being interpreted as 'apply minus url'
Is there a way I can force the interpreter to do the right thing? Or is there some way to refer to a top-level object, and put the index in quotes, like this?
a.apply-url(href="#{this['apply-url']}")
I'm not all that familiar with Jade, but I have looked into it a little bit before. After playing around a while here, I was able to get this to work:
a.apply-url(href="#{locals['apply-url']}")
{"apply-url": "foo"}
produces:
<a href="foo" class="apply-url"></a>
This works because this particular implementation stores the data in a local variable named locals
which is then closed over by the templating function. As far as I can tell, this is an implementation detail, and I wouldn't necessarily expect this to work in other Jade implementations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With