Comments (31)
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.
On a related note could be shorten the tag for
element
toelem
? :)
Sure, could probably do both 😜
from legacy-twig-view.
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.
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.
As always "When it's ready" :)
from legacy-twig-view.
No worries. Congrats on your wedding and enjoy your honeymoon 🙂
from legacy-twig-view.
Thank you, enjoying it a lot 😎 !
from legacy-twig-view.
5.0
is out 🎉
from legacy-twig-view.
Targeting CakePHP 4.0 (or 3.7) only?
from legacy-twig-view.
@ADmad && @markstory Any things on cake's wishlist for 5.0 (targeting cakephp 4.0)?
from legacy-twig-view.
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.
@markstory looking into how to sanely do that 👍
from legacy-twig-view.
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.
@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.
@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.
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.
@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.
@WyriHaximus Yes, that would be really useful on Helper proxy functions.
from legacy-twig-view.
Merging 4.x
in master
now:
Will keep you updated, and tag you in relevant PR's for the extra tags and escaping
from legacy-twig-view.
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.
@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.
Is the PHP 7.1 for CakePHP 4 final?
It's final.
from legacy-twig-view.
Is the PHP 7.1 for CakePHP 4 final?
It's final.
Ok cool! How far from releasing are you?
from legacy-twig-view.
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.
@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.
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.
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.
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.
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.
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.
@dereuromark Hopefully this weekend. Will let you know once the tag is out
from legacy-twig-view.
Related Issues (20)
- Deprecation error while running cake bake HOT 1
- Dependabot can't resolve your PHP dependency files HOT 2
- Deprecations warnings HOT 4
- Using include function HOT 1
- Update composer.json to allow twig 3.0 HOT 15
- Dependabot couldn't fetch the branch/reference for cakephp/cakephp-codesniffer
- Unknown "getVars" function HOT 6
- Call to a member function loadTemplate() on null HOT 1
- Disable Twig cache in debug mode
- Align travis and composer scripts with cakephp
- Move to cakephp namespace with backwards compatible alias
- Align phpcs settings HOT 1
- Align code coverage with cakephp
- The unit tests will be failed on CakePHP 4.1.x version HOT 2
- update links
- Issue with Twig when trying to bake in cakephp 3.x HOT 1
- Name conflict with Twig default filter HOT 4
- mb_convert_encoding(): Illegal character encoding specified HOT 8
- add missing inflectors HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from legacy-twig-view.