Topic on Talk:Requests for comment/HTML templating library/Knockoff - Tassembly

QuestPC (talkcontribs)

Why tags has to be closed explicitly in JSON structures? Nested arrays / objects itself are self-closing:

["<div",["attr",{"id":"id"}],
    ["foreach",{
        "data":"links",
        "tpl":["<a",["attr",{"href":"url"}],">",["text","description"]]
    }],
])

"foreach" is not closed such way, wouldn't that be more consistent? QuestPC (talk) 19:26, 26 March 2014 (UTC)

GWicke (talkcontribs)

TAssembly is designed for easy and efficient processing. Runs of static template text are just encoded as strings, which are emitted verbatim by the runtime. Those runs often contain many tags, which is much more efficient than representing each tag as a JSON (or XML/HTML DOM) structure.

QuestPC (talkcontribs)

I just read about knockout.js. Sounds interesting, but I just did not really like how nested templates are implemented. They are not functional but like usual iterators: http://stackoverflow.com/questions/7313554/nested-templates-with-knockoutjs-and-mvc-3-0?rq=1 Nesting is lost in template definition, it would be better if actual nesting was preserved.

<script type="text/html" id="TopTemplate">
    <li >    
        <p>${name}</p>
        <ul data-bind=" template: {name:  'NestedTemplate' , foreach:  parents } " style="list-style-type:circle;margin-left:15px">
        <script type="text/html" id="NestedTemplate">         
            <li>
                <p>${name}</p>
                <ul data-bind=" template: {name:  'parentTemplate' , foreach:  children } " style="list-style-type:circle;margin-left:15px">
                </ul>
            </li>
          </script>
        </ul>
    </li> 

</script>

However that's better than plain string output, anyway. QuestPC (talk) 16:51, 31 March 2014 (UTC)

QuestPC (talkcontribs)

I read more about knockout.js. Then I liked it and started to use in my non-MediaWiki projects. It's quite nice library indeed. The only thing I miss is more complex "if:" binding than just a null / boolean / zero comparsion. It would be great to have a PHP port indeed - either for MediaWiki and standalone. I guess the whole skinning could be ported into knockout syntax. Thank you for pointing to this library.

Reply to "JSON content"