Template Reference

Quick-reference tables for everything available in gingembre templates.

Filters

FilterArgsDescription
upperUppercase string
lowerLowercase string
capitalizeCapitalize first letter
titleTitle Case
trimStrip leading/trailing whitespace
escapeHTML-escape
safeOutput as raw HTML
lengthNumber of items/characters
firstFirst item of sequence
lastLast item of sequence
reverseReverse a sequence
sortSort ascending
joinsepJoin sequence into string
splitpatSplit string into array
defaultvalueFallback if undefined/null
typeofType 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_segmentsSplit URL path into segments
path_firstFirst segment of URL path
path_parentParent URL path
path_basenameLast 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
definedVariable exists
undefinedVariable doesn't exist
noneValue is null
stringValue is a string
numberValue is a number
mappingValue is an object/dict
iterableValue is a sequence/array
oddNumber is odd
evenNumber 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)