I use Hogan js for my template and require js as a module loader. They have the necessary libraries, such as jquery js, hogan js, require js in place.
index.html below
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>RequireJS - AMD</title> <script data-main="main" src="require.js"></script> <script id="tmpl-heading" type="text"> <h3>{{heading}}</h3> <p>{{article}}</p> </script> </head> <body> </head> <body> <div id="heading"></div> </body> </html>
and main js below
require(['jquery', 'hogan'], function($, hogan){ var headingData = { heading: "Some heading goes here", article: "<a href='http://www.lipsum.com'>Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit. Donec varius, velit pulvinar sollicitudin auctor, nibh nibh mattis diam, vel elementum tortor urna ac diam. Sed tellus neque, gravida nec facilisis et, pellentesque quis enim." }; var hSource = $("#tmpl-heading").html(); var hTemplate = Hogan.compile(hSource); var hData = hTemplate.render(headingData); $("#heading").html(hData);
My problem: in the browser, the text in the anchor tag does not appear as a link and is displayed as text.
however, if I do not use hogan and something like below, the result will be as expected. The link is displayed correctly.
require(['jquery', 'hogan'], function($, hogan){ var headingData = { heading: "Some heading goes here", article: "<a href='http://www.lipsum.com'>Lorem ipsum</a> dolor sit amet, consectetur adipiscing elit. Donec varius, velit pulvinar sollicitudin auctor, nibh nibh mattis diam, vel elementum tortor urna ac diam. Sed tellus neque, gravida nec facilisis et, pellentesque quis enim." }; $("#heading").html(headingData.article); });
Please indicate to me the necessary changes that must be made when using Hogan (I am sure that I must have missed some important bit, but could not figure it out), and I would have to make the binding on the front side as a link. Thank you in advance.