Closed a-guerrero closed 8 years ago
You may use Attribute Stacking:
$dir= "http://my-site/content"
img(src=$dir, src="/assets")
or simple PHP syntax:
$dir= "http://my-site/content"
img(src=$dir."/assets")
But original Jade Compiler works with vars without specific syntax: :-(
- var dir= "http://my-site/content"
img(src=dir + "/assets")
With this code I have error:
Uncaught exception 'Tale\Jade\Compiler\Exception' with message 'Failed to compile Jade: Failed to parse Jade: Attributes in elements and mixins need a name
(attribute at 8:20)
$dir = "http://my-site/content"
img(src=$dir."/assets")
//or
$dir = "http://my-site/content"
img(src!="#{$dir}/assets")
http://sandbox.jade.talesoft.io/id-56fd4487857ff.html
Notice the !=
instead of =
at the attribute to avoid value escaping (Tale Jade escapes everything by default for security reasons)
Always remember that this is Jade made for PHP, not just a simple fork and syntax change :)
Please tell me if this is resolved for you.
Thanks!, both solutions work great for me! :grin:.
Hi, I'm trying to use interpolation in elements attributes like this (the code is just and example to demonstrate the error):
Output:
I had to play with the variable to make it work, but it would be nice to have interpolation in elements attributes just like the original implementation :-)