npm.io
0.0.4 • Published 3 years ago

angular-template-expressions-extractor

Licence
MIT
Version
0.0.4
Deps
5
Size
15 kB
Vulns
0
Weekly
0

Angular Template Expressions Extractor

This module can be used to parse Angular templates and extract Javascript-compatible expressions from them, which can then be used for static analysis like extracting intl messages in formatjs.

See test/expressions.test.ts for examples.

Input Output
{{ a + b }} a + b
<div [thing]="a + b" /> a + b
<div *thing="1 | async" /> async(1)
<div *thing="a; else b" /> a,"else",b
<div [thing]="a?.b?.c" /> a?.b?.c
<div (thing)="action(1, 2)" /> action(1, 2)
<option *ngFor="let country of countries | keyvalue"> "let","of",keyvalue(countries)