constant
¶
constant
检查变量的值是否与常量完全相同。可以使用全局常量或类常量:
1 2 3 | {% if post.status is constant('Post::PUBLISHED') %}
the status attribute is exactly the same as Post::PUBLISHED
{% endif %}
|
也可以从对象实例测试常量:
1 2 3 | {% if post.status is constant('PUBLISHED', post) %}
the status attribute is exactly the same as Post::PUBLISHED
{% endif %}
|