Skip to content

Conversation

@ggmichaelgo
Copy link
Contributor

@ggmichaelgo ggmichaelgo commented Dec 13, 2024

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 ggmichaelgo requested review from a team, Maaarcocr and ianks December 13, 2024 20:26
@macournoyer
Copy link
Contributor

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?

@ggmichaelgo
Copy link
Contributor Author

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 ggmichaelgo marked this pull request as draft December 14, 2024 01:16
@ggmichaelgo ggmichaelgo changed the title don't add comment node to the nodelist Remove blank nodes from AST with omit_blank_nodes option Jan 7, 2025
@ggmichaelgo ggmichaelgo marked this pull request as ready for review January 7, 2025 18:26
@isaacbowen
Copy link

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

@ggmichaelgo ggmichaelgo marked this pull request as draft January 10, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants