b-html-plus

0.3.0 • Public • Published

b-html-plus

A template language based on b-html.

It is also an example for b-html's format option.

Usage

import assert from 'assert';
import bHtml from 'b-html-plus';
 
let source = `<ul
  <li
    @b-repeat user in users
    @b-text user.name
`;
let template = bHtml(source);
let context = {
  users: [
    { name: 'bouzuya' },
    { name: 'emanon001' }
  ]
};
let html = template(context);
assert(html === '<ul><li>bouzuya</li><li>emanon001</li></ul>');

Syntax

  • b-attr <attrs> ... attributes (e.g. @b-attr width: w, height: h)
  • b-html <html> ... innerHTML (e.g. @b-html html)
  • b-if <condition> ... remove tree if condition is falsy (e.g. @b-if show)
  • b-repeat <item> in <list> ... repeat (e.g. @b-repeat user in users)
  • b-text <text> ... innerText (e.g. @b-html text)

License

MIT

Author

bouzuya <m@bouzuya.net> (http://bouzuya.net)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.0
    1
  • 0.2.0
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i b-html-plus

Weekly Downloads

1

Version

0.3.0

License

MIT

Last publish

Collaborators

  • bouzuya