Giter Site home page Giter Site logo

app.js's Introduction

app.js

A simple and light app toolkit. Declaratively binds data to dynamic views as defined by data attributes in HTML.

Launch

var app = new App();

Views

<div data-view="name" data-data="path.to.data">
    <h1>Hello world</h1>
</div>

Where 'name' is the key of a view function in app.views and 'path.to.data' points to an object in app.data. The view is defined as a function that takes the DOM node and the data object as arguments:

app.views['name'] = function(node, data) {
    // Listen for changes to data.
    observe(data, function(data) {
        // Do something to the node.
    });
};

Templates

<div data-template="name">
    <h1>{{ prop }}</h1>
</div>

The template is stored as a DOM node in app.templates[name], and can be cloned and rendered with app.render(name, context), where context is an object with properties that match template tags โ€“ such as {{ prop }}.

Data

Data must be defined before it is needed by a view. In the case of views already in the DOM, this means before jQuery(document).ready().

Other than that, there is no restriction about how your data is organised. The data-data attribute accepts a dot delimited path so you can find your data in any arbritrary structure inside of app.data.

app.js's People

Contributors

stephband avatar

Watchers

 avatar Marco Bonetti avatar James Cloos 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.