You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Twig.php follows the same rules for printing booleans as PHP does.
In PHP "false" is printed as empty string. "true" is printed as 1
{{ 1 and 0 }}
Print:
0
should print:
I'm not sure how to fix this.
I should change Twig.expression.operator.parse to add the PHP-like strings, but isn't that function both used for outputting text and the evaluating operator expressions?
I could also, make Twig.expression.operator.parse add the proper types to the stack and then parse the output at the end (the expression "a && b" add a 1 if true and 0 if false), but I don't understand the code well enough to see if this is a good idea or not.
The text was updated successfully, but these errors were encountered:
@justjohn , what was your main goal when you decided to create a port of PHP Twig?
Do you want Twig.js to render templates exactly how Twig.php does it?
As @m-abs reported, sometimes there is significant difference between Twig.php and Twig.js results.
If you think Twig.js should be an exact port of Twig.php, I can start working on it.
My goal is to mimic twig PHP as closely as possible. In some cases that's not really possible, since JavaScript and PHP are different languages, but for cases like this, I see no reason not to make the change.
If you're interested in creating a fix, go for it, I'd be happy to merge it in.
I think the suggestion about annotating the output from @m-abs is the right way to go, since that provides an easy path to adding automatic escaping of output, which is currently the major difference between twig php and twig js.
Twig.php follows the same rules for printing booleans as PHP does.
In PHP "false" is printed as empty string. "true" is printed as 1
Print:
should print:
I'm not sure how to fix this.
I should change Twig.expression.operator.parse to add the PHP-like strings, but isn't that function both used for outputting text and the evaluating operator expressions?
I could also, make Twig.expression.operator.parse add the proper types to the stack and then parse the output at the end (the expression "a && b" add a 1 if true and 0 if false), but I don't understand the code well enough to see if this is a good idea or not.
The text was updated successfully, but these errors were encountered: