Skip to content

Implement raw tag parsing in BlockBody#1378

Closed
peterzhu2118 wants to merge 1 commit into
masterfrom
pz-raw-block-body
Closed

Implement raw tag parsing in BlockBody#1378
peterzhu2118 wants to merge 1 commit into
masterfrom
pz-raw-block-body

Conversation

@peterzhu2118
Copy link
Copy Markdown
Contributor

When implementing serialization, I noticed that the Raw tag did not use a BlockBody for storing its body which is different than how other blocks work. This makes serialization difficult as this becomes a special case that needs to be handled.

This PR adds a parsing mode for raw tags inside BlockBody that parses for raw tags.

@dylanahsmith
Copy link
Copy Markdown
Contributor

Won't we have that special case either way? Since we want to serialize the body as a raw string for the raw tag, rather than as a normal liquid block. The advantage of this liquid and liquid-c change isn't clear without additional context about the follow-up changes that will use this.

Comment thread lib/liquid/tags/raw.rb
def parse(tokens)
@body = +''
while (token = tokens.shift)
if token =~ FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should remove FullTokenPossiblyInvalid from this class, since it's now in BlockBody

@peterzhu2118
Copy link
Copy Markdown
Contributor Author

The alternative to this PR is Shopify/liquid-c#135 which writes the raw tags directly as an instruction.

@macournoyer
Copy link
Copy Markdown
Contributor

Would Shopify/liquid-c#135 also replace Shopify/liquid-c#134?

@peterzhu2118
Copy link
Copy Markdown
Contributor Author

peterzhu2118 commented Jan 4, 2021

Yeah. Shopify/liquid-c#135 does basically this PR + Shopify/liquid-c#134 but implemented differently (without modifying liquid implementation).

@peterzhu2118 peterzhu2118 deleted the pz-raw-block-body branch January 4, 2021 20:42
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