Socket
Socket
Sign inDemoInstall

reactive-handlebars

Package Overview
Dependencies
8
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reactive-handlebars

A miniature library for updating DOM elements reactively and for providing observer methods to oberve objects passed to the handlears templates


Version published
Weekly downloads
0
Maintainers
1
Install size
7.77 MB
Created
Weekly downloads
 

Readme

Source

reactive-handlebars

A miniature library to update handlebars templates reactively.

Handlebars is one of the most popular templating engines. Complicated UIs, data visualizations, and systems of calculations are examples of just a few problems where organising code becomes really hard while updating the templates on change.

How can reactive-handlebars simplify your templates ?

  • Updating variables will update their values where used in DOM.
  • Maximizing separation of concern and providing clean and declarative way of organizing the code.
  • Observing the data passed to the template through observers. (If the listeners are set on object keys that are passed to the template).
  • Abstraction over asynchronous HTTP calls by setting promises to the templates.

Getting Started

Install
npm install reactive-handlebars
Dependencies
  • jquery
  • lodash.js
  • handlebars.js

Usage

Counter Example

Initialise
let counter = new ReactiveHbs({
    container: '.mount',
    template: '#tpl',
    data: {
      count: 0
    }
 
});

Helpers
counter.helpers({
    multiplyByTwo() {
        return counter.get('count') * 2;
    }
});

Events
counter.events({
    'click [name="increment-count"]': (e, elm, tpl) => {
        tpl.set( 'count', tpl.get('count') + 1 );
    }
});
Observers
counter.reactOnChange('count', { throttle: 100 }, (tpl) => {
    console.log('count have been changed ', tpl.get('count'));
});

// turn the observer off when not needed
counter.stopReactOnChange('count');

Next Steps

See this [Demo] (http://codepen.io/hjaveed/pen/ZprdyP)

Check out these [examples] (https://github.com/hadijaveed/reactive-handlebars/tree/master/examples) in the wild

Keywords

FAQs

Last updated on 18 Oct 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc