Skip to content

Instantly share code, notes, and snippets.

@timneutkens
Created September 23, 2016 14:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timneutkens/d9750b10d130af5921e2627f33ed73ee to your computer and use it in GitHub Desktop.
Save timneutkens/d9750b10d130af5921e2627f33ed73ee to your computer and use it in GitHub Desktop.
Magento2 mage/template example

How to use mage/template in Magento2

define(['mage/template'], function (mageTemplate) {
  // mageTemplate is a wrapper around `_.template`. See http://underscorejs.org/#template
  var template = mageTemplate('<underscore.js template string>')
  var html = mageTemplate({ /* optional data object */ })
  document.getElementById('<id here'>).innerHTML = html
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment