* the items filter, which has been deprecated for quite a long time now, has been removed
* the range filter has been converted to a function: 0|range(10) -> range(0, 10)
+ * the constant filter has been converted to a function: {{ some_date|date('DATE_W3C'|constant) }} -> {{ some_date|date(constant('DATE_W3C')) }}
Changes:
{{ var|raw }} {# var won't be escaped #}
{% autoescape off %}
-``constant`` (new in Twig 0.9.9)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-``constant`` returns the constant value for a given string:
-
-.. code-block:: jinja
-
- {{ some_date|date('DATE_W3C'|constant) }}
-
``merge`` (new in Twig 0.9.10)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{{ i }},
{% endfor %}
+``constant``
+~~~~~~~~~~~~
+
+``constant`` returns the constant value for a given string:
+
+.. code-block:: jinja
+
+ {{ some_date|date(constant('DATE_W3C')) }}
+
Extensions
----------
'upper' => new Twig_Filter_Function('strtoupper'),
'lower' => new Twig_Filter_Function('strtolower'),
'striptags' => new Twig_Filter_Function('strip_tags'),
- 'constant' => new Twig_Filter_Function('constant'),
// array helpers
'join' => new Twig_Filter_Function('twig_join_filter'),
{
return array(
'fn_range' => new Twig_Function($this, 'getRange'),
+ 'fn_constant' => new Twig_Function($this, 'getConstant'),
);
}
return range($start, $end, $step);
}
+ public function getConstant($value)
+ {
+ return constant($value);
+ }
+
/**
* Returns a list of filters to add to the existing list.
*
--TEST--
"constant" filter
--TEMPLATE--
-{{ date|date('DATE_W3C'|constant) }}
+{{ date|date(constant('DATE_W3C')) }}
--DATA--
$d = date_default_timezone_get();
date_default_timezone_set('UTC');
--DATA--
return array('foo' => 'bar')
--EXPECT--
-fn_range,foo,_parent,
-fn_range,_parent,
-fn_range,foo,foo1,_parent,
-fn_range,foo1,_parent,
+fn_range,fn_constant,foo,_parent,
+fn_range,fn_constant,_parent,
+fn_range,fn_constant,foo,foo1,_parent,
+fn_range,fn_constant,foo1,_parent,