0.4.4 • Published 8 years ago

fray.parser v0.4.4

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

fray.parser

Template parser

Usage

CLI

echo '<div class="greeting">Hello { user.name }!</div>' | parser

Programatically

var parser = require('fray.parser');

var template = '<div class="greeting">Hello { user.name }!</div>';
console.log(JSON.stringify(parser.parse(template), null, 2));

Output:

{
  "type": "Root",
  "children": [
    {
      "type": "ElementNode",
      "name": "div",
      "attrs": {
        "class": "greeting"
      },
      "children": [
        {
          "type": "TextNode",
          "value": "Hello"
        },
        {
          "type": "ExpressionNode",
          "value": [
            "user",
            "name"
          ]
        },
        {
          "type": "TextNode",
          "value": "!"
        }
      ]
    }
  ]
}

Install

npm install fray.parser

Contributing

PRs are welcome!

Unit tests

git clone https://github.com/frayjs/parser
cd parser
npm install
npm test

References

License

MIT

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago