DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
  • Legacy
    • can-ejs
      • tags
        • <% CODE %>
        • <%= CODE %>
        • <%== CODE %>
        • <%# CODE %>
      • methods
        • from
    • can-list
    • can-map
    • can-map-backup
    • can-map-define
    • can-view-href
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Legacy
  • /
  • can-ejs
  • /
  • from
  • / On this page
    • from

      function

      Return a template loaded from an element.

      • source

      ejs.from(id)

      Load a template from an HTML element (usually a <script> element) specified by id. This is used typically for demo purposes.

      For example, with a <script> tag as follows in your HTML:

      <script type='text/ejs' id='my-template'>
      <h1><%= message %></h1>
      </script>
      

      Load and render that template like:

      var template = ejs.from("my-template");
      template({message: "Hello There!"});
      

      Parameters

      1. id {String}:

        The id of the element, whose innerHTML will be used to create a template.

      Returns

      {function}:

      A renderer function that will render the template.

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.