Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Render simple mustache template as scope value?

$
0
0
For rendering a template string you have to use the actual engine (can.view.mustache) because can.view will normally try to look up the string as a filename. The engine will return a renderer function that you can call with the data to get a document fragment or call rendererFunction.render() to get HTML content that you can include into a template (unescaped with {{{data}}}).
  1. var message = 'this is a string with a <a href="{{route-root}}/something">link</a>.';
  2. var renderer = can.view.mustache(message);

  3. renderer(data) // -> Document fragment
  4. renderer.render(data) // -> HTML

Viewing all articles
Browse latest Browse all 3491

Trending Articles