Is it possible / reasonable to use an external template engine, for example, dust .js or any other with angular ones?

I was tempted to use dust.js templates because it provides much better performance for rendering the user interface by caching the templates.

But in my current project we use angularjs. Is it even possible / wise to use dust.js or any other templated engine with angular js ??

Even if I use dust.js, I will lose two-way binding.?

Please suggest considering a relatively large SPA ..?

PS I am new to both angular and dust.

+2
javascript angularjs
source share
1 answer

Sounds like a good use case for filter !

Remember that dust.js is an asynchronous renderer, but if you have already downloaded everything , then dust will work synchronously ( most of the time )

app.module('yours',[]).filter('dustRender', function(){ return function(input, templateName){ var rendered; dust.render(templateName, input, function(err, out){ if('string' === typeof out){ rendered = out; } err && console.error('Dust rendering error!', err); }); return rendered || input; }; }); 

template

 <span>{{ modelData | dustRender:'registered-dust-template' }}</span> 

Note: Angular $ sanitize output, e.g. html.

+1
source share

All Articles