Giter VIP home page Giter VIP logo

altr's Introduction

What is altr and why would I use it?

altr is a lightweight templating engine that is backed by the native DOM.

Rather than blowing away large portions of the DOM and recreating those nodes with each update, altr modifies only the nodes that have changed. As a result of this approach, altr is performant and a good citizen of the DOM: altr updates do not interfere with DOM event listeners or CSS3 animations.

Install:

if you are using browserify (you should)

run npm install altr, then simply var altr = require('altr').

otherwise

download altr.js and include it in your html before your other JavaScript files

<script type="text/javascript" src="/path/to/altr.js"></script>

Basic Usage:

js:

var el = document.getElementById('root')
  , template = altr(el)

template.update({
    name: "world"
  , list: [1,2,3]
})

//later
template.update(new_state)

html:

<div id="root">
  <h1>hello, {{ name }}!</h1>
  <ul altr-for="item in list">
    <li altr-text="item"></li>
  </ul>
</div>

##Tags: altr currently supports these tags: if, for, value, html, attr, and text. It is under active development, more will be added soon.

##Values: You can also insert values into text nodes or non altr-* attributes using the syntax: {{ dot.path.to.value }}.

Filters:

I have only written an addition filter so far, but the API is functional. They look like {{ num|add(5) }}.

Filters are through streams, so they can be used synchronously, asynchronously, or to update values over time (e.g. a countdown or transition).

altr's People

Contributors

awinterman avatar hayes avatar jarofghosts avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.