Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove blank nodes from AST with omit_blank_nodes option #1870

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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, ianks and Maaarcocr 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! 🥰

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