Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render HTML as rendered HTML in jQuery.tmpl()?

I can't assign HTML properly using jQuery.tmpl(). If i pass value of something as html tag it is rendered as as it is instead of HTML tags rendered on page

<div id="window">
    <script id="lines" type="text/x-jquery-tmpl">
        <div id="${id}" class="line ${type}"><span>${name}</span>: ${body}</div>
    </script>
</div>



var line = {
            name: 'John',
            body: '<strong>hello</strong>
        };
        $('#lines').tmpl(line).appendTo('#window');
like image 634
eugeneK Avatar asked Jun 06 '11 07:06

eugeneK


People also ask

What is Tmpl in JQuery?

Selvakumar Arumugam. JQuery templating is a fast and efficient technique to render client-side templates using a JSON data source. It refers to the client-side data binding method with the JQuery. JQuery templating is a fast and efficient technique to render client-side templates using a JSON data source.

How to render HTML in Reactjs?

React's goal is in many ways to render HTML in a web page. React renders HTML to the web page by using a function called ReactDOM. render() .

What is render in HTML?

Rendering is a process used in web development that turns website code into the interactive pages users see when they visit a website. The term generally refers to the use of HTML, CSS, and JavaScript codes. The process is completed by a rendering engine, the software used by a web browser to render a web page.


1 Answers

You can wrap the template variable with {{html body}} to override the default encoding behavior.

like image 137
Dvir Avatar answered Oct 14 '22 04:10

Dvir