liquid_raw 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. {% comment%}<!--
  2. The liquid_raw helper is a way to display raw liquid code, as opposed to parsing it.
  3. Normally you'd use Liquid's built in 'raw' tag.
  4. The problem is GitHub Jekyll does not support the current Liquid release.
  5. GitHub Jekyll supports the deprecated 'literal' tag.
  6. Using one will break the other if you plan to deploy to GitHub pages.
  7. see: https://github.com/mojombo/jekyll/issues/425
  8. Since I don't want to mess with Liquid versions, I'll just rewrite the way I
  9. intend to give liquid examples. It's not an elegant solution by any means:
  10. Usage:
  11. 1) Define a 'text' variable with the block of liquid code you intend to display.
  12. 2) Pass the text variable to include JB/liquid_raw
  13. example:
  14. {% capture text %}|.% for tag in tags_list %.|
  15. <li><a href="|.{ site.var.tags_path }.||.{ tag[0] }.|-ref">|.{ tag[0] }.| <span>|.{tag[1].size}.|</span></a></li>
  16. |.% endfor %.|
  17. |.% assign tags_list = null %.|{% endcapture %}
  18. {% include JB/liquid_raw %}
  19. As seen here, you must use "|." and ".|" as opening and closing brackets.
  20. -->{% endcomment%}
  21. {% if site.JB.liquid_raw.provider == "custom" %}
  22. {% include custom/liquid_raw %}
  23. {% else %}
  24. <pre><code>{{text | replace:"|.", "&#123;" | replace:".|", "&#125;" | replace:">", "&gt;" | replace:"<", "&lt;" }}</code></pre>
  25. {% endif %}
  26. {% assign text = nil %}