Accessing the content of a tag

17 views
Skip to first unread message

brainfck

unread,
Dec 14, 2009, 7:30:42 AM12/14/09
to Liquid Templates
Hi,

I am currently developing a custom tag.

How can I access the content between the tag begin and end?

For example:
{% menu %}
<li>{{ menu_item }}</li>
{% endmenu %}

I want to get "<li>{{ menu_item }}</li>".
How can I achieve this?


Best regards

Simon Russell

unread,
Dec 14, 2009, 5:32:52 PM12/14/09
to liquid-t...@googlegroups.com
I don't have any code right in front of me to check, but if you
inherit from Block instead of Tag, you should have access to that. I
think you can get the block contents before the code is run (so you'll
see {{ menu_item }}, but I'm not entirely sure.
> --
>
> You received this message because you are subscribed to the Google Groups "Liquid Templates" group.
> To post to this group, send email to liquid-t...@googlegroups.com.
> To unsubscribe from this group, send email to liquid-templat...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liquid-templates?hl=en.
>
>
>

Nick

unread,
Dec 22, 2009, 10:46:58 AM12/22/09
to Liquid Templates
Take a look at the Capture tag:
http://github.com/tobi/liquid/blob/master/lib/liquid/tags/capture.rb

In the render method, calling super.join will return the tag's
content.

Reply all
Reply to author
Forward
0 new messages