Skip to content

Instantly share code, notes, and snippets.

@PetrKaleta
Created January 1, 2012 23:13
Show Gist options
  • Save PetrKaleta/1548614 to your computer and use it in GitHub Desktop.
Save PetrKaleta/1548614 to your computer and use it in GitHub Desktop.
How to append rendered Hogan.js template into some DOM element
# use pre-compiled template
piicHTML = HoganTemplates.piic.render { link: '#', url: 'http://foo.bar/image.jpg' }
# used just for htmlString => DOMElement conversion
el = document.createElement 'span'
el.innerHTML = piicHTML
# append all first childs
@piicsContainer.appendChild el.firstChild while el.firstChild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment