Some Meteor Blaze helpers for HTML manupulations.
meteor add imajus:html-helpers
Package provides following global Blaze helpers:
dump(...args)
– Returns JSON-fiedargs
as a string.
<pre>{{dump currentUser currentRoute}}</pre>
activeClass(current, expected, initial)
– Whencurrent
equalsexpected
, returns'active'
string literal. Ifinitial
value istrue
, helper returns'active'
for emptycurrent
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'
, seewhen
from imajus:common-helpers.
<ul class="menu">
<li class="{{activeClass currentRoute 'home' true}}">Home</li>
<li class="{{activeClass currentRoute 'contact'}}">Contact Us</li>
...
</ul>
numberClass(num)
– Returns one of'positive'
,'negative'
or'zero'
literal values depending onnum
value.selected(current, expected, initial)
– Addsselected
attribute whencurrent
equalsexpected
. Ifinitial
value istrue
, helpers will also adds attribute in case ofcurrent
is empty.
<select>
<option {{selected value 'first' true}}>First</select>
<option {{selected value 'second'}}>Second</select>
</select>
checked(current, expected, initial)
– Addschecked
attribute whencurrent
equalsexpected
. Ifinitial
value istrue
, helpers will also adds attribute in case ofcurrent
is empty.
<input type="radio" {{checked value 'first' true}}> First
<input type="radio" {{checked value 'second'}}> Second
disabled(current, expected, initial)
– Addsdisabled
attribute whencurrent
equalsexpected
. Ifinitial
value istrue
, helpers will also adds attribute in case ofcurrent
is empty.
<button {{disabled value 'first' true}}>First</button>
<button {{disabled value 'second'}}>Second</button>