Skip parsing for documentation

59 views
Skip to first unread message

Dylan

unread,
Aug 2, 2009, 4:17:11 PM8/2/09
to Liquid Templates
Hey, I am using Jekyll to power a documentation microsite for a
project. And our app's theming API is built from Liquid as is Jekyll's
rendering system. This seems to make it impossible to actually write
the documentation since liquid tries to render any code block I try to
write for documentation - is there any existing way to enclose liquid
markup in a block that tells Liquid to not render the contents of the
block?

The custom Jekyll method I've written is below but it doesn't stop the
parsing it just presents whatever is passed within the block for
parsing - actually not useful :(

I can't be the only person out there with this problem (documenting
liquid markup within a liquid environment). Any thoughts?

---

module Jekyll
class SkipBlock < Liquid::Block
def render(context)
return super
end
end
end
Liquid::Template.register_tag('skip', Jekyll::SkipBlock)

---

And ideally, I'd be able to then just enclose liquid tags thusly:

{% skip %}
<pre>
<html>
<body>
<ol id="portfolios">
{% for portfolio in portfolios %}
<li>{{ portfolio.name }}</li>
{% endfor %}
</ol>
</body>
</html>
</pre>
{% endskip %}

---

Thanks again

Dylan

Brian Candler

unread,
Aug 2, 2009, 4:28:48 PM8/2/09
to liquid-t...@googlegroups.com
On Sun, Aug 02, 2009 at 01:17:11PM -0700, Dylan wrote:
> I can't be the only person out there with this problem (documenting
> liquid markup within a liquid environment). Any thoughts?

Here is an ugly solution, but it may be worth considering:

template = Liquid::Template.parse(<<EOS)
{% assign braces='{{' %}
{% assign percent='{%' %}
You write liquid markup like this:
{{braces}} foo }}
EOS
puts template.render

#or:
#template.assigns['braces'] = '{{'
#template.assigns['percent'] = '{%'

Dylan

unread,
Aug 2, 2009, 5:13:35 PM8/2/09
to Liquid Templates
Thanks, Brian, I wonder why I didn't think of just replacing the
braces themselves during the render. It is possibly less than ideal,
but well, it works and it's less of a hassle than dropping jekyll/
liquid entirely. So I just did something similar to your solution.

Thanks for the quick thought!

Błażej Kosmowski

unread,
Jan 8, 2015, 4:52:30 AM1/8/15
to liquid-t...@googlegroups.com
That is very late response - but I just faced the same problem when mixing liquid and angular. I've found out there is something like {% raw %} {% endraw %} that solves the issue :)


I hope it helps anybody having the same problem 
Reply all
Reply to author
Forward
0 new messages