Render array inside template



  • @psychobunny . Hi , I am trying to render an array inside a template , I have this code:
    [code]
    var data = {
    results:[]
    }
    function renderTest( req, res, next) {
    results = ['a','b','c','d'];
    data.results = results;
    res.render("mytemplate", data);
    [/code]

    In the template.tpl I have:
    {results.length}
    <!-- BEGIN results -->
    {results}
    <!-- END results -->

    I get only 4 which is the length, I am unable to display the array content. Could you please help me how to do this ?



  • Ok , solved it , I looked in your tests, worked using this :
    <!-- BEGIN results -->
    @_value // without the _
    <!-- END results -->
    I see that if i put it without _ in post it renders as Object , you should have a look at this.


Log in to reply
 

Suggested Topics

| |