Handlebars helper for generating form elements
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec
README.md
UNLICENSE
handlebars.el.form.js
package.json

README.md

handlebars.el.form

{{{el-field name="foo"}}}

Content helper providing form inputs and controls for Handlebars using handlebars.el

Version

1.0.5

Installation

npm install handlebars.el.form

Registering the helper

 var Handlebars = require("handlebars");
 var FormHelper = require("handlebars.el.form");
 FormHelper.registerHelpers(Handlebars);

Using the helpers

See project website for more detailed examples

el-field

{{{el-field name="foo"}}}
    → «<div class="control control-foo"><label for="input-foo">Foo</label><div class="edit"><input id="input-foo" name="foo" type="text"></div></div>»
  • Can render in edit or display mode
  • Can output single and multiple inputs
  • Take a Backbone-style model to provide value
  • Take a key to provide labels, help and more

el-text

{{{el-text name="foo"}}}
    → «<input name="foo" type="text">»

el-checkbox

{{{el-checkbox name="foo"}}}
    → «<input name="foo" type="checkbox" value="true">»

el-radio

{{{el-radio name="foo"}}}
    → «<input name="foo" type="radio">»

el-password

{{{el-password name="foo"}}}
    → «<input name="foo" type="password">»

el-file

{{{el-file name="foo"}}}
    → «<input name="foo" type="file">»

el-hidden

{{{el-hidden name="foo"}}}
    → «<input name="foo" type="hidden"»

el-submit

{{{el-submit}}}
    → «<input type="submit">»

el-textarea

{{{el-textarea name="foo"}}}
    → «<textarea name="foo"></textarea>»

el-select

{{{el-select name="foo" options=opts}}}
Context {opts:["a", "b"]}
    → «<select name="foo"><option value="a">a</option><option value="b">b</option></select>»

el-form

{{#el-form}}foo{{/el-form}}
    → «<form method="post">foo</form>»

el-label

{{{el-label content="foo"}}}
    → «<label>foo</label>»

{{#el-label for="bar"}}foo{{/el-label}}
    → «<label for="bar">foo</label>»

el-fieldset

{{#el-fieldset legend="bar"}}<i>foo</i>{{/el-fieldset}}
    → «<fieldset><legend><span>bar</span></legend><i>foo</i></fieldset>»

Tests

npm test

To see output generated by tests

npm run test:output

Unlicense

handlebars.el.form is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/