The template object contains information about the currently active template.
Outputting the template object itself returns the file name of the template used to render the current page, without the .liquid or .json extension.
<!-- On the product.alternate.json template -->
{{ template }}
product.alternate
The template object has the following attributes:
template.directory
Returns the name of the template's parent directory. Returns nil for templates whose parent directory is the /templates folder.
<!-- On the customers/login.liquid template -->
{{ template.directory }}
customers
template.name
Returns the name of the template's base type.
<!-- On the product.alternate.json template -->
{{ template.name }}
product
template.suffix
Returns the custom name of an alternate template. Returns nil if no alternate template is used.
<!-- On the product.alternate.json template -->
{{ template.suffix }}
alternate
More properties
VersaCommerce also provides these properties on the template object:
| Properties | Returns |
|---|---|
include? |
Whether the template name contains the supplied string |