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

Insert markup in template dynamicly.

$
0
0
If I have some template string 

  1. '<p>{{name}}</p>'

Is it possible to insert it to components template using for example helper, so this template would be executed in correct scope?

components template:

  1. can.Component.extend({
  2.   template: '<div>{{templateHelper}}</div>',
  3.   scope: {
  4.      //name is defined in upper scopes
  5.   },
  6.   helpers: {
  7.     templateHelper: function(){return '<p>{{name}}</p>'}
  8.   }
  9. })

So the result would be <div><p>Some name defined in upper scopes</p></div>

Viewing all articles
Browse latest Browse all 3491

Trending Articles