liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Remove blank nodes from AST with omit_blank_nodes option

Open ggmichaelgo opened this issue 11 months ago • 3 comments

By using omit_blank_nodes parse option, Parser will omit Comment node and other empty nodes from the AST.

For example, If tag like this won't be included in the AST:

source = <<~LIQUID
  {% if foo > 1 %}
  {% endif %}
LIQUID

Liquid::Template.parse(source, omit_blank_nodes: true)

ggmichaelgo avatar Dec 13 '24 20:12 ggmichaelgo

I think this means comments won't be available in the AST anymore right? That might break tools using AST walking to inspect comments.

I only know of https://github.com/Shopify/theme-check, but it's deprecated. So might be good.

Do you think that might be an issue?

macournoyer avatar Dec 13 '24 21:12 macournoyer

I think this means comments won't be available in the AST anymore right? That might break tools using AST walking to inspect comments.

I only know of https://github.com/Shopify/theme-check, but it's deprecated. So might be good.

Do you think that might be an issue?

oh good point... it should be configurable to omit these nodes 👍

ggmichaelgo avatar Dec 14 '24 01:12 ggmichaelgo

Hello from an AST-walking codebase! 👋 Thanks for thinking of us! 🥰

isaacbowen avatar Jan 07 '25 19:01 isaacbowen