Search code examples
node.jshogan.jssocketstream

Un-render a template view with hogan.js


Is there any way to un-render a template with hogan.js. You can just hide it, but that leave's a lot of elements with id's and it can mess up further effects on your site.

I have looked around, but can't find an answer to this. Thanks


Solution

  • hogan.js is a templating language. What means that one can easly render different html markups just using some javascript object. It does not have the purpose of manipulating the DOM.

    Lets say you got html like this:

    <body>
      ...stuff...
      <div id="div-1">...stuff...</div>
    </body>
    

    You could use of course jQuery:

    $('#div-1').remove();
    

    Or if it saves trouble you can use pure javascript:

    var elem = document.getElementById('div-1');
    elem.parentNode.removeChild(elem);