bug #2795 Fix float representation in compiled templates (fabpot)

This PR was merged into the 1.x branch.

Discussion
----------

Fix float representation in compiled templates

closes #2788

Commits
-------

e346c2ac fixed float representation in compiled templates
This commit is contained in:
Fabien Potencier
2019-01-08 17:50:30 +01:00
3 changed files with 16 additions and 1 deletions
+1
View File
@@ -2,6 +2,7 @@
* switched generated code to use the PHP short array notation
* dropped PHP 5.3 support
* fixed float representation in compiled templates
* added a second argument to the join filter (last separator configuration)
* 1.36.0 (2018-12-16)
+1 -1
View File
@@ -175,7 +175,7 @@ class Twig_Compiler implements Twig_CompilerInterface
setlocale(LC_NUMERIC, 'C');
}
$this->raw($value);
$this->raw(var_export($value, true));
if (false !== $locale) {
setlocale(LC_NUMERIC, $locale);
@@ -0,0 +1,14 @@
--TEST--
Twig compiles floats properly
--TEMPLATE--
{% set val2 = 0.0 %}
{{ val is same as (0.0) ? 'Yes' : 'No' }}
{{ val2 is same as (0.0) ? 'Yes' : 'No' }}
{{ val is same as (val2) ? 'Yes' : 'No' }}
--DATA--
return array('val' => 0.0)
--EXPECT--
Yes
Yes
Yes