2.8.2 • Published 6 months ago
@shopify/liquid-html-parser v2.8.2
This module provides the Liquid HTML parser that powers the prettier plugin, linter and language server for Liquid-powered Shopify themes.
It turns a .liquid file contents into an Abstract Syntax Tree (AST) that contains both Liquid and HTML nodes.
Installation
# with npm
npm install @shopify/liquid-html-parser
# with yarn
yarn add @shopify/liquid-html-parserUsage
import { toLiquidHtmlAST, LiquidHtmlNode, NodeTypes } from '@shopify/prettier-plugin-liquid';
const ast: LiquidHtmlNode = toLiquidHtmlAST(`
<body>
{% for product in all_products %}
<img src="{{ product | image_url }}">
{% endfor %}
</body>
`);You should know
Because Liquid is very permissive, things like the name of an HTML tag may have a surprising type: an array of LiquidVariableOutput | TextNode.
This is because the following use cases are supported by the parser:
{% # compound html tag names %}
<tag-{{ name }}>
</tag-{{ name }}>
{% # compound html attribute names %}
<img data-{{ attr_name }}="...">License
MIT.
2.8.2
6 months ago
2.3.0
9 months ago
2.1.2
11 months ago
2.2.0
11 months ago
2.1.1
11 months ago
2.5.0
8 months ago
2.3.2
9 months ago
2.4.0
9 months ago
2.7.0
8 months ago
2.6.0
8 months ago
2.8.1
7 months ago
2.8.0
7 months ago
2.1.0
12 months ago
2.0.5
1 year ago
2.0.4
1 year ago
2.0.3
2 years ago
2.0.2
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.0
2 years ago