How can I escape curly braces inside jade templates?

Juergen Gutsch picture Juergen Gutsch · Mar 15, 2012 · Viewed 10.1k times · Source

ho can I escape curly braces inside a jade teplate? (I use jade inside node.js)

I want to render jQuery templates to the client. The part I want to escape looks like this:

div(class='clear')
script(id='BoardListTemplate', type='text/x-jQuery-tmpl')
  <p>${Title}</p>
  <ul id="${Id}" class="IterationBoardList">
    <li class="AddNewItem">Add new Item</li>
    {{tmpl(Items) "#BoardListItemTemplate"}}
  </ul>
script(id='BoardListItemTemplate', type='text/x-jQuery-tmpl')
  <li class="Item" id="${{$data.Id}}">
    ${$data.Description}<br />
    Assigned to: ${$data.AssignedTo}<br/>
  StoryPoints: ${$data.StoryPoints}</li>
script(src='/javascripts/Scrummr.Engine.js', id='BoardListItemTemplate', type='text/javascript')

many thanks

Answer

Golo Roden picture Golo Roden · Mar 15, 2012

You have to use the pipe ( | ) sign in front of each line inside the script block.

See https://gist.github.com/2047079 for an example.