Socket
Socket
Sign inDemoInstall

@shopify/liquid-html-parser

Package Overview
Dependencies
4
Maintainers
25
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @shopify/liquid-html-parser

Liquid HTML parser by Shopify


Version published
Weekly downloads
59K
decreased by-7.6%
Maintainers
25
Install size
2.07 MB
Created
Weekly downloads
 

Readme

Source


logo
Liquid HTML parser

Version License CI

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-parser

Usage

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.

FAQs

Last updated on 14 Feb 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc