Test if a Twig Variable is of a certain type in Craft-CMS.
##Usage:
####Test: of_type('test_name')
Check if a variable is of a specific type.
{% set test_var = craft.entries %}
{% if test_var is of_type('object') %}
true
{% endif %}
Available Tests:
####Filter: get_type
Return the type of a variable.
{% set test_var = craft.entries %}
{{ test_var|get_type }}
will output:
object
Alias for php's gettype()
##Install:
- Move the
twigtypetest
directory into thecraft/plugins/
directory. - Go to Settings -> Plugins and enable 'Twig Type Tests'.