@buxlabs/ejs-lexer

1.1.0 • Public • Published

ejs-lexer

npm (scoped)

ejs lexer

Installation

npm install @buxlabs/ejs-lexer

Usage

const lexer = require('@buxlabs/ejs-lexer')
const tokens = lexer('<div><%- foo %></div>')
console.log(tokens)

How does it work?

It translates a string into an array of tokens with type and value

<div><% foo %><%- bar %><%= baz %><%_ biz %><%# boss %></div>
[
  { type: 'string', value: '<div>' },
  { type: 'evaluate', value: 'foo' },
  { type: 'escape', value: 'bar' },
  { type: 'interpolate', value: 'baz' },
  { type: 'slurp', value: 'biz' },
  { type: 'comment', value: 'boss' },
  { type: 'string', value: '</div>'}
]

There are six types: string, evaluate, escape, interpolate, slurp and comment. The value of the ejs specific types is trimmed.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @buxlabs/ejs-lexer

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

6.63 kB

Total Files

5

Last publish

Collaborators

  • buxlabs-dev
  • emilos