Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Jade interpolation for script template

I am using node.js and express.j s to render an index.jade page which contains several script blocks taht contain templates to be used via backbone and underscore. The issue I am facing is that due to the inclusiong of <%= %> style variables within the templates, the Jade rendering is failing. The following code snippet causes a syntax error:

script#tpl-things-list-item(type='text/template')
  td 
    a(href=<%= _id %>) link text
  td <%= name %>
  td <%= age %>

Note that it is only a problem when I use a variable inside the href value, if I remove the entire href, this snippet works just fine. Is there a way to work around this? I'd like to continue using Jade to define the templates as it is very concise but this is a show stopper.

like image 462
nickbona Avatar asked Oct 23 '22 01:10

nickbona


1 Answers

Got it.

!!! 5
html(lang='en')
    head
        title= title
    body
        h1= "Hello World!"
        script#tpl-things-list-item(type='text/template')
            td
                a(href!="<%= _id %>") link text
            td <%= name %>
            td <%= age %>
like image 95
Lyn Headley Avatar answered Oct 27 '22 10:10

Lyn Headley