Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Add proper parsing and printing of Liquid filters #46

Merged
merged 1 commit into from
Aug 8, 2022

Conversation

charlespwd
Copy link
Collaborator

@charlespwd charlespwd commented Aug 4, 2022

In this PR:

  • Adds support for parsing filters inside Liquid drops.
  • Prints expression as they are printed in Add Liquid Variable expression support #41
  • Adds opinionated logic for when to break filters, and when to break filter arguments
input: (printWidth: 1)
{{ x | filter1 | filter2: pos1, pos2, "hi" | filter3: key1: val1 }}

output:
{{
  x
  | filter1
  | filter2: pos1,
    pos2,
    "hi"
  | filter3:
    key1: val1
 }}

Fixes #45

Also, a quick poll on the partner slack seems to indicate most folks prefer breaking the tag delimiters on an empty line.

I'm going to go forward with that style for now and leave folks to vote on a config to support the other style (in alignment with our opinionated guiding principle) in a separate issue.

@charlespwd charlespwd force-pushed the feature/45-liquid-filters branch 4 times, most recently from a25d4a7 to 8402d75 Compare August 5, 2022 15:55
@charlespwd charlespwd requested a review from a team August 5, 2022 15:56
@charlespwd charlespwd assigned charlespwd and unassigned charlespwd Aug 5, 2022
@charlespwd charlespwd marked this pull request as ready for review August 5, 2022 15:56
@charlespwd charlespwd linked an issue Aug 5, 2022 that may be closed by this pull request
Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @charlespwd!

@charlespwd charlespwd force-pushed the feature/40-liquid-variable-expression branch from e7b7e61 to 79a00f7 Compare August 8, 2022 14:33
Base automatically changed from feature/40-liquid-variable-expression to main August 8, 2022 14:47
@charlespwd charlespwd merged commit 2961479 into main Aug 8, 2022
@charlespwd charlespwd deleted the feature/45-liquid-filters branch August 8, 2022 14:48
@shopify-shipit shopify-shipit bot temporarily deployed to production August 8, 2022 15:01 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prettier Liquid: Filters
2 participants