Skip to content

"Twig supports binary operations (+, -, *, /, ~, %, and, or)" incorrect print of boolean #88

Open
@m-abs

Description

@m-abs

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions