Skip to content

victor-sm/Craft-TwigTypeTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Craft-TwigTypeTest

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:

  1. Move the twigtypetest directory into the craft/plugins/ directory.
  2. Go to Settings -> Plugins and enable 'Twig Type Tests'.