Template

A super lightweight and overtly simple templating util until we have enough reason to include a more robust templating solution within Rizzo.

Note: Given the simple nature of this util, it will only work one level deep within the given object and has no looping or conditional logic whatsoever.

Usage

<script id="my-template" type="text/html">
  <p class="copy--body">
    My name is <strong>{{name}}</strong> and I'm a <em>{{position}}</em>.
  </p>
</script>
<div class="js-rendered-template"></div>
require([ "public/assets/javascripts/lib/utils/template" ], function(Template) {
  var obj = { name: "slothbot", position: "robot" },
      template = $("#my-template").text(),
      rendered;

  // Where the magic happens...
  rendered = Template.render(template, obj);

  $(".js-rendered-template").html(rendered);
});

The above would render the following markup:

<div class="js-rendered-template">
  <p class="copy--body">
    My name is <strong>slothbot</strong> and I'm a <em>robot</em>.
  </p>
</div>