Talesoft / tale-jade

A complete and fully-functional implementation of the Jade template language for PHP

Home Page:http://jade.talesoft.codes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error set attribute

est-by opened this issue · comments

  • $pref_url="public/client/"
    html(lang='en')
    head
    block head
    //ERROR
    script(src="#{$pref_url}node_modules/systemjs/dist/system.src.js")
    //OK
    script(src=$pref_url."node_modules/systemjs/dist/system.src.js")

Could you give some more explanation and also format your example so that I can see the actual problem?

Both compile correctly for me
http://sandbox.jade.talesoft.io/id-5730955f76d8f.html

This code indicates a problem
bag.zip

Alright, what you're running into is a simple escaping-problem.

Jade escapes everything by default. It doesn't help using !{$pref_url}, because the attribute value is an expression and gets escaped separately from the interpolation.

If you want it unescaped, use the following

link(rel="stylesheet", href!="#{$url_root}app.css")

That works (I tested it here)

Notice the != to define the atttribute, which tells Jade: Don't escape this attribute.

Notice that this is wanted behaviour, since it protects your site from XSS-attacks from feeding user input into Jade files (automatically, by default).

Thank you! Everything is working! Thank you for the quick response.