Skip to content
Micro template com recursos do puro do javascript a funcao curry e com memoizacao para evitar processamento repitidos
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
README.md
bower.json
gulpfile.js
package.json
script.txt
template.js

README.md

$template

Micro template com recursos do puro do javascript a funcao curry e com memoizacao para evitar processamento repitidos

<script type="text/html" id="user_tmplate">
  <% while (users.hasNext()) { %>
    <li>
      <a href="<%= users.next().url %>"><%= users.current().name %></a>
    </li>
  <% } %>
</script>
this.Ninja(['$iterator', '$template'], function ($iterator, $template) {

  function $(selector) {
    return document.querySelector(selector);
  }

  function render(html) {
    $('body').innerHTML = html;
  }

  function users() {
    return $iterator([{ url: '#', name: 'cleber.programmer' }]);
  }

  $template($('#user_tmplate').innerHTML, users());

});
Something went wrong with that request. Please try again.