0
votes

This is my code.. (snipped) (jsRender version v1.0.0-beta)

    <script type="text/javascript" src="resources/javascript/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="resources/javascript/jsrender.min.js"></script>

    <script>
    $(document).ready(function(){ 
        data.past = [ { text: 'HEllo' }, {text: 'bye'} , {text: 'bye'} ]
        var template = $.templates("#takeover");            
        output = template.render(data.past);
        $("table.events").append(output);
    }
    </script>

    <body>
    <script id="takeover" type="text/x-jsrender">
    <tr id="{{:takeover_id}}" class="dynamic">
        <td>{{:text}}{{if text}}yep{{else}}nope{{/if}}</td>
    </tr>
    </script>   
    <table class="events">
        <thead>
            <td>Takeover text</td>
        </thead>
    </table>
    </body>

So, as expected, three .dynamic tr's are inserted into table.events.

However: instead of Hello, bye, bye; each <td> says simply yepnope.

I can't see what I'm doing wrong.

Update: When I try console.log("{{test}}test") this spits out test in the console, could some script be interfering with the double curly brackets?

1
Found the issue, the router I'm using in node utilises a template system and that's stripping out all {{ tags }} - Colin Palmer
You might be interested in using JsRender's feature for choosing your own tag delimiters. See stackoverflow.com/questions/29493005/… - BorisMoore

1 Answers

0
votes
<script id="takeover" type="text/x-jsrender">
    <tr id="{{:takeover_id}}" class="dynamic">
        <td>{{:text}}{{if text}}yep{{else}}nope{{/if}}</td>
    </tr>
    </script> 
<table class="events">
        <thead>
            <td>Takeover text</td>
        </thead>
    </table>

JS:

var vm = [ { text: 'HEllo' }, {text: 'bye'} , {text: 'bye'} ];
var template = $.templates("#takeover");            
        output = template.render(vm);
        $("table.events").append(output); 

Output:

Takeover text HElloyep byeyep byeyep