Page MenuHomePhabricator

[MEX] Add support for simple comparative binary expressions to php-vuejs-templating
Closed, ResolvedPublic

Description

php-vuejs-templating does not currently support binary expressions like the following:

<p v-if="type === 'string'">
  {{ value }}
</p>

Including such an expression in a template results in the following stacktrace:

[c1cbf45f3a4a944f5fa6d9ec] /w/index.php?title=Q12&debug=1&mobileaction=toggle_view_mobile RuntimeException: Unable to parse complex expression of type Peast\Syntax\Node\BinaryExpression

Backtrace:

from /var/www/html/w/vendor/wmde/php-vuejs-templating/src/JsParsing/PeastExpressionConverter.php(82)

Add support for BinaryExpressions so that such conditions can be evaluated.

Acceptance Criteria

  • php-vuejs-templating is able to process binary expressions that appear in templates when their Javascript semantics is a boolean comparison (including '===', '!==', '==', '!=', '<', '>', '<=', '>=') in the case that both sides of the binary expression evaluate to a string, integer or bool
  • the semantics of the evaluation of the expression should conform to Javascript semantics (and not PHP semantics)

Event Timeline