Giter Site home page Giter Site logo

meteor-handlebar-helpers's Introduction

#Handlebar-helpers Is a simple way of using sessions and collections in the Meteor handlebars template environment

Have a look at Live example

There are 4 simple handlers

  • {{getSession}}
  • {{sessionEquals}}
  • {{find}}
  • {{findOne}}

##How to use?

####1. Install:

    mrt add handlebar-helpers

Requires Meteorite get it at atmosphere.meteor.com

###Get session variable: The {{getSession 'foo'}} helper returns the value of session variable 'foo' In the template:

<h1>{{getSession 'foo'}}</h1>

In the controller:

  Session.set('foo', 'bar');

###Compare session to value: The {{sessionEquals 'foo' 'bar'}} compares session 'foo' value with the string value 'bar'. Can use ``integerandboolean``` values for comparing aswell. arrays and objects are invalids due to contrains in Meteor and handlebars

{{#if sessionEquals 'foo' 'bar'}}
  session 'foo' equals the value 'bar'
{{else}}
  session 'foo' doesn't equal the value 'bar'
{{/if}}

###Get data in from collection The {{find 'foo' '{}'}} and {{findOne 'foo' '{}'}} will return qurey '{}' result from collection defined as var foo = new Meteor.Collection("myFooCollection") From the demoHelpers example:

  {{#each find 'testCollection' '{}' '{ "sort": { "createdAt":1 } }'}}
    {{name}} - timeStamp: {{createdAt}}</br>
  {{else}}
    You never clicked the button
  {{/each}}

Note: query and options should be formatted as json, since attributes as Objects and Arrays aren't supported by the Meteor handlebars

meteor-handlebar-helpers's People

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.