Spelt Docs

Filters

Filters allow you to transform the value of a variable in your template. For example:

{{ title | uppercase }}

Or:

{{ url | prepend: site.url }}

Date filters

Description Filter and output
Date
Convert a date to its string representation using specified format.
{{ date | date: EEE, MMM dd yyyy HH:mm }}
Fri, Jan 29 2016 13:42
Date to string
Convert a date to its default string representation using your system's localization settings.
{{ date | date_to_string }}
e.g.: 29 January 2016
Date to RFC-822
Convert a date into the RFC-822 format used for RSS feeds.
{{ date | date_to_rfc822 }}
Fri, 29 Jan 2016 13:42:45 +0100
Date to XML Schema
Convert a Date into XML Schema (ISO 8601) format.
{{ date | date_to_xmlschema }}
2016-01-29T13:42:45+01:00

String filters

Description Filter and output
Lowercase
Convert a string to lowercase text.
{{ Spelt | lowercase }}
spelt
Uppercase
Convert a string to uppercase text.
{{ spelt | uppercase }}
SPELT
Capitalize
Capitalize each word in a string.
{{ some sentence | capitalize }}
Some Sentence
Markdownify
Convert a Markdown-formatted string into HTML.
{{ # Title | markdownify }}
<h1>Title</h1>
XML Escape
Escape some text for use in XML.
{{ this&that | xml_escape }}
this&amp;that
URL Encode
Convert string for use in URLs by percent-encoding disallowed characters.
{{ some string | url_encode }}
some%20string
Prepend
Prepend characters to a string.
{{ , World! | prepend: Hello }}
Hello, World!
Append
Append characters to a string.
{{ Hello | prepend: , World! }}
Hello, World!
Replace
Replace all occurrences of a string with specified replacement.
{{Hey there!|replace:there,you}}
Hey you!
Strip HTML
Strip all HTML tags from a string.
{{<h1>Hello</h1>, World! | strip_html}}
Hello, World!
Strip newlines
Remove line breaks/newlines from a string.
{{ post.excerpt | strip_newlines }}
Truncate
Truncate a string to specified number of characters.
{{It's raining cats and dogs|truncate:17}}
It's raining cats
Number of words
Count the number of words in some text.
{{content | strip_html | number_of_words}}
42

Array filters

Description Filter and output
Join
Join the elements of an array with the specified character.
{{ categories | join: ", " }}
static site generators, documentation
Array to sentence
Convert an array into a sentence. Useful for listing tags.
{{ tags | array_to_sentence_string }}
foo, bar, and baz

Math filters

Description Filter and output
Divide by
Divides an output by a number.
{{ 100 | divided_by: 10 }}
10.0
Ceil
Rounds an output up to the nearest integer.
{{ 4.3 | ceil }}
5
Floor
Rounds an output down to the nearest integer.
{{ 4.9 | floor }}
4