imajus:html-helpers

v0.0.4Published 6 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Overview

Some Meteor Blaze helpers for HTML manupulations.

Installation

meteor add imajus:html-helpers

Related packages

Contents

Package provides following global Blaze helpers:

  • dump(...args) – Returns JSON-fied args as a string.
1<pre>{{dump currentUser currentRoute}}</pre>
  • activeClass(current, expected, initial) – When current equals expected, returns 'active' string literal. If initial value is true, helper returns 'active' for empty current value as well. To be used in lists-like interactive UI components, like menus.

For more general helper which you can use to return other string literal rather than 'active', see when from imajus:common-helpers.

1<ul class="menu">
2  <li class="{{activeClass currentRoute 'home' true}}">Home</li>
3  <li class="{{activeClass currentRoute 'contact'}}">Contact Us</li>
4  ...
5</ul>
  • numberClass(num) – Returns one of 'positive', 'negative' or 'zero' literal values depending on num value.
  • selected(current, expected, initial) – Adds selected attribute when current equals expected. If initial value is true, helpers will also adds attribute in case of current is empty.
1<select>
2  <option {{selected value 'first' true}}>First</select>
3  <option {{selected value 'second'}}>Second</select>
4</select>
  • checked(current, expected, initial) – Adds checked attribute when current equals expected. If initial value is true, helpers will also adds attribute in case of current is empty.
1<input type="radio" {{checked value 'first' true}}> First
2<input type="radio" {{checked value 'second'}}> Second
  • disabled(current, expected, initial) – Adds disabled attribute when current equals expected. If initial value is true, helpers will also adds attribute in case of current is empty.
1<button {{disabled value 'first' true}}>First</button>
2<button {{disabled value 'second'}}>Second</button>