-
Notifications
You must be signed in to change notification settings - Fork 97
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
How can I create a custom block to capture data but not expose to template when rendering? #321
Comments
Duplicate for #266 |
Agree, this is not handy and worth to fix this.
This is synthetic limitation and can be dropped.
I would go with ThreadLocal but that is a dirty hack. |
Do you feel like opening the registry up for general usage would be appropriate? It seems like the registry is being used to track internal state information, so feels like this might be the best way to go. Is there a reason the Would you be open to a PR that allowed creating new registry items? If so, would you prefer that you need to do something like call an |
So it sounds like you'd be open to a PR in which the limitation of I'd be happy to work on a PR. |
|
Fantastic! Thank you so much! |
Are you planning on pushing 0.9.2.1 to Maven or should I just compile it myself? |
Sorry I forgot to click free buttons yesterday. Will finish the release today. |
This time I finished the flow. |
I'm looking to implement something like what LiquidJS has for capturing blocks:
https://liquidjs.com/tags/layout.html#Multiple-Blocks
In my case, my current thinking is I want to capture the output inside a block but not expose that captured data to rest of the template. So I might have something like:
This text inside the block would be captured, but not available to the template like
{% capture }
would be.In looking at the
Capture
class for inspiration, I see it's storing the results in theTemplateContext
and I can use aTemplate.ContextHolder
if I want to extract that information after rendering. However, it puts the data in the normal context, which makes it available in the template.I thought I might be able to extend the
TemplateContext
class to add tracking of these exported captures, but it doesn't look like there's a way to have theTemplate
instance use a customTemplateContext
.My next thought was I might be able to create a new "registry" entry in the
TemplateContext
instance, but thegetRegistry()
code throws an exception if you try to create a registry that does not exist.Any thoughts on how I might capture some data and not expose it to the template, but be able to read it in the a
ContextHolder
later?The text was updated successfully, but these errors were encountered: