Skip to content

Conversation

@iamdadmin
Copy link
Contributor

Closes #1937

Updated /packages/view/src/Elements/PhpIfElement.php

     public function compile(): string
     {
         if ($condition = $this->wrappingElement->consumeAttribute(':isset')) {
-            $condition = sprintf('isset(%s)', $condition);
+            $condition = preg_replace('/\$\w+/', 'isset($0)', $condition);

Updated docs and tests, and real-world tested it in an app, both in single-case and multi-case.

Expression logic is untested, because all the function does is wrap isset around a $var, so it remains the responsibility of a developer to produce expressions which evaluate to true or false as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend :isset element handling in view to support multiple vars

1 participant