JsRender Rendering HTML

I am using jsRender to display my data on an html page. The data is getting great. However, in some content elements, HTML text (such as a hyperlink) appears as text. There is a way in the jquery template to render HTML using {{html. Is there something similar in jsRender? My code is as follows:

<p>
{{ =Status}}   //need to convert this to HTML so it should appear as hyperlink.
</p> 

Thank.

+5
source share
4 answers

JsRender beta candidate is now missing (see Boris post from last night http://www.borismoore.com/2012/03/approaching-beta-whats-changing-in_06.html )

I wrote a quick script to show how to render HTML here: http://jsfiddle.net/johnpapa/NfUGB/

, {{ > yourProperty}} HTML-. {{: yourProperty}}, .

<script id="template" type="text/x-jsrender">
    <p>
    {{:foo}}
    </p>
    <ul>
    {{for testData}}
        <li>{{:name}} - {{:markup}} - {{>markup}}</li>
    {{/for}}
    </ul>
</script>
<div id="div1"></div>

.

var vm = {
    foo: "names",
    testData: [
        {
            name: "John", 
            markup: "<span style='background: yellow'>John</span>"
        },
        {
            name: "Boris", 
            markup: "<span style='background: orange'>Boris</span>"
        }
    ]
};

$("#div1").html($("#template").render(vm));​
+9

{{:Status}} HTML-.

+6

jsRender, , <, > HTML-. , jsRender

escapeMapForHtml = {
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;"
},

escapeMapForHtml = {
},

HTML !

EDIT: , (, 03_no-encoding.html) . ,

{{=Status!}

jsRender HTML

+2

..

<p>
{^{ =Status}}   
</p>
0

All Articles