Giter VIP home page Giter VIP logo

Comments (31)

WyriHaximus avatar WyriHaximus commented on May 30, 2024 3

As always "When it's ready" :)

Cool, the underlying question was: How fast does this needs to be done. But I'll get onto some stuff after my Honeymoon and dedicate some days to straightening things out and get them CakePHP 4 ready 👍 .

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024 2

On a related note could be shorten the tag for element to elem? :)

Sure, could probably do both 😜

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024 1

Probably CakePHP 4.0, but if 3.7 isn't to much of an hassle that would be awesome. The thing is I would prefer to support the same minimum PHP version as CakePHP 4.0 with this 5.0 release.

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024 1

Just skimming through twig docs I couldn't find a way to tell twig to disable escape for specific vars used in {{ }}.

So avoiding the need for using |raw would probably require registering new tag for helpers as it's done for cells and element. Usage would be like {% helper 'Foo.method' %}. This would make the usage a bit more verbose but on the flip side it would provide the benefit of being able to use helper auto loading like we have for .ctp files. Currently you need to explicitly load the helpers you want to use in twig template.

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024 1

As always "When it's ready" :)

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024 1

No worries. Congrats on your wedding and enjoy your honeymoon 🙂

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024 1

Thank you, enjoying it a lot 😎 !

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024 1

5.0 is out 🎉

from legacy-twig-view.

inoas avatar inoas commented on May 30, 2024

Targeting CakePHP 4.0 (or 3.7) only?

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

@ADmad && @markstory Any things on cake's wishlist for 5.0 (targeting cakephp 4.0)?

from legacy-twig-view.

markstory avatar markstory commented on May 30, 2024

I would love to help find a way to not need |raw all over the place. I find it noisy and trains people to use |raw which can be dangerous.

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

@markstory looking into how to sanely do that 👍

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

There might be something deeper in the API to do this, not entirely sure.

Like the idea, not 100% sold on the syntax but I'll get an experiment on this weekend to implement it and see where we can take it from there 👍 .

from legacy-twig-view.

markstory avatar markstory commented on May 30, 2024

@ADmad TwigView could use reflection to generate twig functions for all defined helper methods. Twig functions can indicate that they are escapers. This would add a bit of overhead but could be something that is 'compiled' or cached.

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024

@markstory Yeah using reflection in TwigView is an option but I would prefer if the additional work could be done through Twig itself (with some additional code) instead of adding reflection in our view class.

On a related note could be shorten the tag for element to elem? :)

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024

Having helpers as regular variables also has the drawback that if someone doesn't follow conventions and for e.g. sets a view var named Html, the variable will be overwritten by helper instance.

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

@ADmad just been digging around and found this: https://twig.symfony.com/doc/2.x/advanced.html#automatic-escaping
We could/should select specific functions and filters that will be safe to be output rawly into the resulting template

from legacy-twig-view.

markstory avatar markstory commented on May 30, 2024

@WyriHaximus Yes, that would be really useful on Helper proxy functions.

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

Merging 4.x in master now:

image

Will keep you updated, and tag you in relevant PR's for the extra tags and escaping

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024

I was looking into updating master to run with CakePHP 4 and got stuck. There's a bit of chicken and egg problem as Bake requires TwigView and TwigView itself has Bake as dev dependency 🙂

I tried to work on TwigView first ignoring the Bake dependency but the 1st blocker is the api-clients/test-utilities. Cake 4 requires PHP 7.1+ and phpunit 7.0+ but there's no version of test-utilities which satisfies these dependencies.

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

@ADmad lets fix that! If api-clients/test-utilities blocks something we can drop it and required-dev dependencies directly. Mainly use it as convenience to include test utilities but it isn't blocking anything. Is the PHP 7.1 for CakePHP 4 final? Or might it go to 7.2 before 4.0.0 is released?

Also we could make bake an optional dev dependency that we load on the CI when running tests but isn't a dev requirement if that untangles things.

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024

Is the PHP 7.1 for CakePHP 4 final?

It's final.

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

Is the PHP 7.1 for CakePHP 4 final?

It's final.

Ok cool! How far from releasing are you?

from legacy-twig-view.

FinlayDaG33k avatar FinlayDaG33k commented on May 30, 2024

I've been taking a look at this repo lately because we are considering to implement this in our project, however, I feel like it's "odd" to have to rename all the .ctp files to .twig files to use TwigView.
I wonder if it would be possible to use the regular .ctp files instead?

from legacy-twig-view.

ADmad avatar ADmad commented on May 30, 2024

@FinlayDaG33k "regular" .ctp files contain PHP code :). Why would you unnecessarily confuse any new dev joining your project by using .ctp extension instead of the default .twig for Twig files?

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

It's not only that, TwigView will fallback to .ctp files if it can't find the matching .twig file. So both formats are supported and you can iterate your way into support it file by file. There are also some IDE benefits such as PHPStorm picking up it's a twig file without having to configure that.

from legacy-twig-view.

FinlayDaG33k avatar FinlayDaG33k commented on May 30, 2024

Why would you unnecessarily confuse any new dev joining your project by using .ctp extension instead of the default .twig for Twig files?

Well, to me, it feels more confusing that everything is .ctp and then suddenly there are some .twig files hanging around.

It's not only that, TwigView will fallback to .ctp files if it can't find the matching .twig file.
Ah I see.

This wasn't in the documentation, I'll add that in a bit :)

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

It's not only that, TwigView will fallback to .ctp files if it can't find the matching .twig file.
Ah I see.

This wasn't in the documentation, I'll add that in a bit :)

Cool 👍 !

from legacy-twig-view.

dereuromark avatar dereuromark commented on May 30, 2024

the files should be whatever they are. so if those are twig templates, then the file extension should be .twig.
this also makes it able to leverage IDEs here to introspect them more easily.

As for the new Cake4 release, any plans on releasing a beta already or sth?
https://github.com/cakephp/bake/blob/master/composer.json#L24

"wyrihaximus/twig-view": "dev-master"

this is blocking other plugins to become stable.

cakephp/bake 2.0.1 requires wyrihaximus/twig-view dev-master -> satisfiable by wyrihaximus/twig-view[dev-master] but these conflict with your requirements or minimum-stability.

from legacy-twig-view.

dereuromark avatar dereuromark commented on May 30, 2024

PS: Once you got a beta tag out, like the other plugins now, you can add the strawberry: FriendsOfCake/awesome-cakephp#334 :)

from legacy-twig-view.

WyriHaximus avatar WyriHaximus commented on May 30, 2024

@dereuromark Hopefully this weekend. Will let you know once the tag is out

from legacy-twig-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.