lib/client/myelements.jquery.js
function(el, data, done) {

    if (!el.template) {
      $myelements.debug("Creating EJS template from innerHTML for element: ", el);
      // Save the compiled template only once
      try {
        el.template = new EJS({
          element: el
        });

      } catch (e) {
        console.error("myelements.jquery: Error parsing element's innerHTML as an EJS template: ", e.toString(),
          "\nThis parsing error usually happens when there are syntax errors in your EJS code.",
          "\nThe elements that errored is ", el);
        el.template = undefined;
        return;
      }
    }
    try {
      // pass a locals variable as render scope`
      var html = el.template.render({
        locals: data
      });
    } catch (e) {
      console.error("myelements.jquery: Error rendering element's template: ", e.toString(),
        "\nThis rendering error usually happens when refering an undefined variable.",
        "\nThe elements that errored is ", el);
      return;
    }
    el.innerHTML = html;
    // $this.html(html);

    // Ensure every form in the element
    // is submitted via myelements.
    // Called after render because the original forms get dumped on render
    $myelements.handleFormSubmissions(el);
    if (typeof done === "function") {
      return done(html);
    }
  }
function(el, data, done) {

    if (!el.template) {
      $myelements.debug("Creating EJS template from innerHTML for element: ", el);
      // Save the compiled template only once
      try {
        el.template = new EJS({
          element: el
        });

      } catch (e) {
        console.error("myelements.jquery: Error parsing element's innerHTML as an EJS template: ", e.toString(),
          "\nThis parsing error usually happens when there are syntax errors in your EJS code.",
          "\nThe elements that errored is ", el);
        el.template = undefined;
        return;
      }
    }
    try {
      // pass a locals variable as render scope`
      var html = el.template.render({
        locals: data
      });
    } catch (e) {
      console.error("myelements.jquery: Error rendering element's template: ", e.toString(),
        "\nThis rendering error usually happens when refering an undefined variable.",
        "\nThe elements that errored is ", el);
      return;
    }
    el.innerHTML = html;
    // $this.html(html);

    // Ensure every form in the element
    // is submitted via myelements.
    // Called after render because the original forms get dumped on render
    $myelements.handleFormSubmissions(el);
    if (typeof done === "function") {
      return done(html);
    }
  }
function ( el , data , done ) { if ( ! el . template ) { $myelements . debug ( "Creating EJS template from innerHTML for element: " , el ) ; // Save the compiled template only once try { el . template = new EJS ( { element : el } ) ; } catch ( e ) { console . error ( "myelements.jquery: Error parsing element's innerHTML as an EJS template: " , e . toString ( ) , "\nThis parsing error usually happens when there are syntax errors in your EJS code." , "\nThe elements that errored is " , el ) ; el . template = undefined ; return ; } } try { // pass a locals variable as render scope` var html = el . template . render ( { locals : data } ) ; } catch ( e ) { console . error ( "myelements.jquery: Error rendering element's template: " , e . toString ( ) , "\nThis rendering error usually happens when refering an undefined variable." , "\nThe elements that errored is " , el ) ; return ; } el . innerHTML = html ; // $this.html(html); // Ensure every form in the element // is submitted via myelements. // Called after render because the original forms get dumped on render $myelements . handleFormSubmissions ( el ) ; if ( typeof done === "function" ) { return done ( html ) ; } }
Re render the element template. It saves it because
on every render, the EJS tags get dumped, so we compile
the template only once.

@param {HTMLElement} el
@param {Object} scope data to be passed to the EJS template render.
@param {Function} done called when rendering is done
- {Error} err. Null if nothing bad happened
- {Jquery collection} $el. the element that was rendered.
- {Object} data. scope data passed to doRender
Re render the element template . It saves it because on every render the EJS tags get dumped so we compile the template only once .