Code Monkey home page Code Monkey logo

hatajs's Introduction

hatajs

js helper for easy work with DOM generation on one-page frontend

Instalation

add jQuery to project

add line to package.json

  "devDependencies": {
    ...
    "hatajs": "github:greeschenko/hatajs",
    ...
  }

and in project root execute

    npm install

Usage

index.html

    ...
    <body>
        <div id="res"></>
    </body>
    ...

/tmpls/test.html (it is view or template)

    <h1>{{greeting}} {{name}}</h1>

/data/test.json (this file simulate request to backend)

{
    "greeting":"Hello",
    "name":"World!"
}

I use ES6 syntax with babel

let test = new Hata(
    '#res',                             // result render element selector
    'tmpls/test',                       // view file without ".html"
    {},                                 // data object if need add data from code
    function(){
        console.lot("test is work");    // hendle function execute after render
    },
    '/data/test.json',                  // request to backend if need
    1000                                // interval timeout for rerender and reload data if need
).render();                             // you can render element now or use test.render() in code

This code render in #res element every 1 sec.

    <h1>Hello World!</h1>

if change /data/test.json to this

[
    {
        "greeting":"Hello",
        "name":"World!"
    },
    {
        "greeting":"Hello",
        "name":"World!"
    },
    {
        "greeting":"Hello",
        "name":"World!"
    }
]

code render in #res element evety 1 sec.

    <h1>Hello World!</h1>
    <h1>Hello World!</h1>
    <h1>Hello World!</h1>

hatajs's People

Contributors

greeschenko avatar

Watchers

 avatar  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.