Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twiggy compiler fixes #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

jcheron
Copy link

@jcheron jcheron commented Jan 16, 2023

  • bug fix : no open issue
  • BC break

Fixed:

These behaviors may have been voluntary choices...
I don't know

raw filter

Twig raw filter is not interpreted.

Twig Expected Latte Actual Latte
{{foo|raw}} {$foo|noescape} {$foo}

see 7aaba40

Twig array access

Access to the element of a Twig array is transformed into access to the member of an object.

Twig Expected Latte Actual Latte
{{bar['foo']}} {$bar['foo']} {$bar->foo}

see 209d1fb

Twig and Twiggy coexisting

pb with Twig already installed in a project (cannot redeclare Twig global functions...)

  • checks with function_exists the previous declaration of the Twig global functions, see c1a06ed

_self replacement with toString

Replacing {{_self}} with {$_self} is problematic:

  • _self with Twig refers to the template instance, using it alone in an expression calls the toString which displays the template name.
  • $_self is not defined with Latte
Twig Expected Latte Actual Latte
{{_self}} {$this->getName()} {$_self}

see 5250d9c

Unit tests

The unit tests have been modified accordingly: see 4a2e2f5

{{array['key']}} => {$array['key']}
{{object->attribute}} => {$object->attribute}
add function_exists test for twig functions
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.

1 participant