Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

canjs + mustache + recursive template rendering

$
0
0
hi all,
i tried to render mustache templates recursively like done in the testcase. my code looks like this:
javascript:

  1. // controller that will care about events
  2. var StructureController = can.Control.extend({
  3.     defaults: {
  4.         viewId: 'jsEditStructure'
  5.     }
  6. }, {
  7.     /**
  8.      * init
  9.      */
  10.     init: function(element, options) {
  11.         this.element.html(can.view(this.options.viewId, options));
  12.     }
  13. });

  14. // my testdata
  15. var options = {
  16.     items: new can.List([{
  17.         name: "item1",
  18.         items: [{
  19.             id: 1,
  20.             name: "subitem1",
  21.             type: "text",
  22.             items: [{
  23.                 id: 2,
  24.                 name: "subsubitem1",
  25.                 type: "text",
  26.                 items: [{
  27.                     id: 2,
  28.                     name: "subsubsubitem1",
  29.                     type: "text",
  30.                 }]
  31.             }]
  32.         }, {
  33.             id: 100,
  34.             name: "subitem2",
  35.             type: "text"
  36.         }]

  37.     }, {
  38.         name: "item2"
  39.     }])
  40. };

  41. var controller = new StructureController('#jsApp', options);

mustache template #jsEditStructure :

  1. new document

    <br>

    <ol>

          {{#items}}

                {{>jsRowStructure}}

          {{/items}}

    </ol>


and the #jsRowStructure template looks like this:

  1. <li>

    {{name}}< br >

      < ol >

      {{#items}}

        {{>jsRowStructure}}

      {{/items}}

      </ol>

    </li>


I'm getting always a '<error>'.
Does anybody know, how to do it right?
Thank you in advance,
roelfsche



Viewing all articles
Browse latest Browse all 3491

Trending Articles