require([ "dojo/query", "dojo/string", "dojo/NodeList-manipulate", "dojo/domReady!" ], function(query, string){ var employee = { "first": "Kevin", "last": "Armstrong", "title": "Designer" }; var template = "${first} ${last} is a great ${title}."; query("#out").html(string.substitute(template, employee, function(str){ return str.toLowerCase() == "designer" ? "<span class='special'>"+str+"</span>": str; })); });
<div id="out"></div>
strong { font-weight: bold; text-decoration: underline; } .special { font-weight: bold; color: #0099CC; }