PHP Classes

File: libs/Twig/doc/tests/constant.rst

Recommend this page to a friend!
  Classes of william amed   Raptor 2   libs/Twig/doc/tests/constant.rst   Download  
File: libs/Twig/doc/tests/constant.rst
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Raptor 2
Framework that takes routes from annotations
Author: By
Last change:
Date: 8 years ago
Size: 631 bytes
 

Contents

Class file image Download
``constant`` ============ .. versionadded: 1.13.1 constant now accepts object instances as the second argument. ``constant`` checks if a variable has the exact same value as a constant. You can use either global constants or class constants: .. code-block:: jinja {% if post.status is constant('Post::PUBLISHED') %} the status attribute is exactly the same as Post::PUBLISHED {% endif %} You can test constants from object instances as well: .. code-block:: jinja {% if post.status is constant('PUBLISHED', post) %} the status attribute is exactly the same as Post::PUBLISHED {% endif %}