mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
DISABLE_THIRD_PARTY_CHECK=Update puppeteer requires type changes Bug: None Change-Id: Ifda85d161fc94567e4cfaaab0acc2da2f2c29d30 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2953266 Auto-Submit: Jan Scheffler <janscheffler@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
parse-literals
Because sometimes you literally need to parse template literals.
Why?
Template literals are often used in JavaScript for HTML and CSS. This library allows developers to extract the strings from the literals for post processing, such as minifying or linting.
Usage
import * as pl from 'parse-literals';
// const pl = require('parse-literals');
const templates = pl.parseLiterals(`
render() {
return html\`
<h1>\${"Hello World"}</h1>
\`;
}
`);
console.log(templates);
// [
// {
// "tag": "html",
// "parts": [
// {
// "text": "\n <h1>",
// "start": 30,
// "end": 41
// },
// {
// "text": "</h1>\n ",
// "start": 57,
// "end": 67
// }
// ]
// }
// ]
Supported Source Syntax
- JavaScript
- TypeScript