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
{.main-image?}
<!-- code here -->
{.end}
Tests the presence of a Main Image for a collection or item.
Excerpt Predicate
{.excerpt?}
<!-- code here -->
{.end}
Tests the presence an excerpt for an item.
Comments Enabled Predicate
{.comments?}
<!-- code here -->
{.end}
Tests if comments are enabled for a particular item.
Disqus Enabled Predicate
{.disqus?}
<!-- code here -->
{.end}
Test is Disqus comments have been enabled (only useful in items with comments enabled).
Video Predicate
{.video?}
<!-- code here -->
{.end}
Tests if an item within a Gallery Collection is a video.
Even Predicate
{.even?}
<!-- code here -->
{.end}
Tests if an item's index position is even.
Odd Predicate
{.odd?}
<!-- code here -->
{.end}
Tests if an item's index position is odd.
Equal Predicate
{.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}
.
Navigation Predicates
These predicates are only used within navigation (.block
) files.
Collection Predicate
{.collection?}
<!-- code here -->
{.end}
Tests if a navigation item is a collection.
External Link Predicate
{.external-link?}
<!-- code here -->
{.end}
Tests if a navigation item is an external link.
Folder Predicate
{.folder?}
<!-- code here -->
{.end}
Tests if a navigation item is a folder.