# @starptech/expression-parser

> Framework agnostic template expression parser

Latest version **0.10.0** (published 2019-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @starptech/expression-parser
pnpm add @starptech/expression-parser
yarn add @starptech/expression-parser
bun add @starptech/expression-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.0 |
| Published | 2019-06-21 |
| First published | 2018-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 286 |
| Author | Dustin Deus |
| Maintainers | starptech |
| Keywords | formatter, prettyhtml, parser, expressions, angular, vue, riotjs, html5 |

## Links

- npm: https://www.npmjs.com/package/@starptech/expression-parser
- Repository: https://github.com/StarpTech/prettyhtml
- Homepage: https://github.com/StarpTech/prettyhtml#readme
- Issues: https://github.com/StarpTech/prettyhtml/issues
- npm.io page: https://npm.io/package/@starptech/expression-parser

## Recent versions

- 0.10.0 (latest) — 2019-06-21
- 0.9.0 — 2019-04-28
- 0.8.17 — 2019-04-07
- 0.8.15 — 2018-12-18
- 0.8.12 — 2018-12-12

## README

# @starptech/expression-parser

Framework agnostic template expression parser

## Installation

```
npm install --save @starptech/expression-parser
```

## Usage

This example shows how we parse HTML

```js
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

```json
{
  "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](https://github.com/riot/parser) template expression parser.

---
_Source: https://npm.io/package/@starptech/expression-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
