Squarespace Developer Platform: APIs, Apps, and Docs
Template Language

JSON-T Predicates

Predicates are special Directives used like sections, except they don't correspond to a variable in the context. They allow you to test for certain system defined features.

The format for a predicate is {.predicate-name?} ... {.end}. You can generally spot a predicate by the trailing question mark.

Collection Predicates

These tags are used in collection template files (.list, .item).

Main Image Predicate

Code
{.main-image?} <!-- code here --> {.end}

Tests the presence of a Main Image for a collection or item.

Excerpt Predicate

Code
{.excerpt?} <!-- code here --> {.end}

Tests the presence an excerpt for an item.

Comments Enabled Predicate

Code
{.comments?} <!-- code here --> {.end}

Tests if comments are enabled for a particular item.

Disqus Enabled Predicate

Code
{.disqus?} <!-- code here --> {.end}

Test is Disqus comments have been enabled (only useful in items with comments enabled).

Video Predicate

Code
{.video?} <!-- code here --> {.end}

Tests if an item within a Gallery Collection is a video.

Even Predicate

Code
{.even?} <!-- code here --> {.end}

Tests if an item's index position is even.

Odd Predicate

Code
{.odd?} <!-- code here --> {.end}

Tests if an item's index position is odd.

Equal Predicate

Code
{.equal? arg1 arg2} <!-- code here --> {.end}

Tests if two alpha-numeric arguments are equal. If true, anything between the condition {.equal?} and {.end} will be output. If either of your arguments may contain spaces, use a delimiter other than a space to ensure an accurate return. For example: {.equal?:arg1:arg2}.

These predicates are only used within navigation (.block) files.

Collection Predicate

Code
{.collection?} <!-- code here --> {.end}

Tests if a navigation item is a collection.

Code
{.external-link?} <!-- code here --> {.end}

Tests if a navigation item is an external link.

Folder Predicate

Code
{.folder?} <!-- code here --> {.end}

Tests if a navigation item is a folder.