Skip to content

Instantly share code, notes, and snippets.

@beryllium
Created September 29, 2014 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beryllium/2896f2eb16a695f1ae15 to your computer and use it in GitHub Desktop.
Save beryllium/2896f2eb16a695f1ae15 to your computer and use it in GitHub Desktop.
Breakpoints in Sculpin
...
<div>
{# Split the post into an array using explode().
Because we provide a length of 2, the remainder
of the post will be stored in the second array
element, even if there are multiple breakpoints. #}
{% set break_array =
post.blocks.content|split('<!-- break -->', 2) %}
{# Output the first element of the array in raw mode #}
{{ break_array[0]|raw }}
{# Detect if there is more to the post. If the post
was only one array element with no breakpoints,
it would all have shown up. This Read More link should
only show up if there is overflow to the post. #}
{% if break_array|length > 1 %}
<p><a href="{{ site.url }}{{ post.url }}">
Read more of this post &raquo;
</a></p>
{% endif %}
</div>
...
@hackzilla
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment