I am using dustjs for front end templating.
I have json data as
var userData = {‘desc’: ‘This content should be shown inside HTML SPAN TAG’};
Dust template:
{userData.desc}
But when I try to render this template, the desc content is shown on page “as the same string” and tag is not shown as HTML span.
if I use {userData.desc|s|h}: span is shown on page as <span>
The only way I could use is {userData.desc|s} : this one shows the span as html tags properly. But |s will unescape script tags as well, which is a risk.
I want to unescape only HTML tags from the json data content, is there any way to achieve this requirement in dustjs..??
you can create a custom filter – this would suit your need better than a helper. just extend dust.filter with your own custom code that does what you want.
refer to my answer here: How do I implement custom rendering logic in dust.js?