Skip to content

Implementing Shopify's Form Tag #84

Answered by jg-rp
AustinWildgrube asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @AustinWildgrube,

template.render_with_context(context, buffer, partial=True, form_content=self.block)

Here you are writing the internal string representation of liquid.ast.BlockNode to the output buffer, which is why HTML block content looks OK, but Liquid tags and variables don't.

Instead, as you have pointed out, you will want to call self.block.render(context, buffer). Rather than returning rendered content, BlockNode.render() writes to the output buffer that you give it.

You could use an intermediate buffer to capture the rendered block content.

from io import StringIO

# ...

    def render_to_output(self, context: Context, buffer: TextIO) -> Optional[bool]:
        buf = StringIO

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@AustinWildgrube
Comment options

@jg-rp
Comment options

Answer selected by jg-rp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants