Created
September 29, 2014 16:49
-
-
Save beryllium/2896f2eb16a695f1ae15 to your computer and use it in GitHub Desktop.
Breakpoints in Sculpin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<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 » | |
</a></p> | |
{% endif %} | |
</div> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍