Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@starptech/expression-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@starptech/expression-parser

Framework agnostic template expression parser

  • 0.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@starptech/expression-parser

Framework agnostic template expression parser

Installation

npm install --save @starptech/expression-parser

Usage

This example shows how we parse HTML

const parse = require('@starptech/expression-parser')
const result = parse(`{ a + /<g></g> b }`, { brackets: ['{', '}'] })

Representation

  • unescape: Indentify a template marker as escaped. This information is useful to understand why a marker was skipped
  • expressions: A list of template expressions
    • start: Start position
    • end: End position
    • text: The content of the expression
{
  "unescape": "",
  "expressions": [
    {
      "start": 1,
      "end": 19,
      "text": " a + /<g></g> b "
    }
  ]
}

Details

There may be more than one expression as part of one attribute value or text node, or only one replacing the entire value or node.

When used as the whole attribute value, there's no need to enclose the expression inside quotes, even if the expression contains whitespace.

Single and double quotes can be nested inside the expression.

To emit opening (left) brackets as literal text wherever an opening bracket is expected, the bracket must be prefixed with a backslash (the JS escape char ''). This character is preserved in the output, but the parser will add a replace property for the attribute or node containing the escaped bracket, whose value is the bracket itself.

Credits

The parser is a modificated version of Riot template expression parser.

Keywords

FAQs

Package last updated on 21 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc