Template Reference

Quick-reference tables for everything available in gingembre templates.

Filters

FilterArgsDescription
upper—Uppercase string
lower—Lowercase string
capitalize—Capitalize first letter
title—Title Case
trim—Strip leading/trailing whitespace
escape—HTML-escape
safe—Output as raw HTML
length—Number of items/characters
first—First item of sequence
last—Last item of sequence
reverse—Reverse a sequence
sort—Sort ascending
joinsepJoin sequence into string
splitpatSplit string into array
defaultvalueFallback if undefined/null
typeof—Type name as string
slicestart, endSubsequence
mapattributeExtract attribute from each item
selectattrattributeKeep items where attribute is truthy
rejectattrattributeRemove items where attribute is truthy
groupbyattributeGroup items by attribute value
path_segments—Split URL path into segments
path_first—First segment of URL path
path_parent—Parent URL path
path_basename—Last segment of URL path

Functions

FunctionArgsReturns
get_sectionpathSection object with title, permalink, pages, subsections, etc.
get_urlpathURL string for a content path
nowformat (default: %Y-%m-%d)Formatted current date/time
buildpositional: step nameOutput of the configured build step
readfileContents of a file as a string
throwpositional: messageAborts rendering with an error

Tests

Use with {% if value is test_name %}.

TestArgsDescription
defined—Variable exists
undefined—Variable doesn't exist
none—Value is null
string—Value is a string
number—Value is a number
mapping—Value is an object/dict
iterable—Value is a sequence/array
odd—Number is odd
even—Number is even
divisiblebyNDivisible by N
containingsubstringContains substring or item
starting_withprefixStarts with prefix
ending_withsuffixEnds with suffix
matchingregexMatches regular expression
eqvalueEqual to
nevalueNot equal to
ltvalueLess than
gtvalueGreater than
levalueLess than or equal
gevalueGreater than or equal

Template tags

TagDescription
{% extends "file.html" %}Inherit from base template
{% block name %}...{% endblock name %}Define/override a block
{% include "file.html" %}Include another template
{% macro name(args) %}...{% endmacro name %}Define a macro
{% for item in list %}...{% endfor %}Loop
{% if cond %}...{% elif %}...{% else %}...{% endif %}Conditional
{% set var = value %}Set a variable
{# comment #}Comment (not in output)