nuǝW pǝuoᴉʇᴉsoԀ ʎlǝʌᴉʇɐƃǝN
Need private packages and team management tools?Check out npm Teams »

@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

Keywords

Install

npm i @buxlabs/ejs-lexer

DownloadsWeekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

6.63 kB

Total Files

5

Last publish

Collaborators

  • avatar
  • avatar