Comments (14)
This is because ocms3 uses twig v3, instead of v1/2 instead and there whole extension system was changed.
from oc-twigextensions-plugin.
I posed this to OCMS help and got the following response:
"Generally, the Twig classes have been renamed to use namespaces. For example, a class can be namespace with the following conversion Twig_Extension_StringLoader → Twig\Extension\StringLoader"
So at the very least it appears to be a naming issue. I'm going through and trying to adjust and will have a note into vojtasvoboda.
from oc-twigextensions-plugin.
Yes sure, why not. Do you have a list of new functions we can use? I can update readme with that.
Anyway, there is a lot of filters we can use in October 3 and it would be fine to have October 3 100% compatible version.
from oc-twigextensions-plugin.
Hello all (@mwahlmueller, @markandmedia, @TimFoerster, @artisticdigital, @maki3000), new version of the plugin is available on the market and is compatible with October 3.1 and PHP 8.0.
A lot of filters/functions were removed because they are part of the October CMS now. See UPGRADE.MD guide to learn more.
On the other hand, some new filters/functions were added: country_timezones, country_name, currency_name, currency_symbol, language_name, locale_name, timezone_name, format_currency, format_number and format_*_number, format_datetime, format_date and format_time - they are part of the official twig/intl-extra package.
from oc-twigextensions-plugin.
We are getting the same error, but only in a test project running octoberCMS V3
from oc-twigextensions-plugin.
Thank you for your answer. I am currently downgrading again to 2.* and trying to avoid automatically installing the 3.*.
I think the issue is on the new Laravel / Symphony Twig support.
from oc-twigextensions-plugin.
@TimFoerster yes you are right I downgraded to 2.2 and it works perfectly.
from oc-twigextensions-plugin.
Any tips on how to solve this? Create a new plugin just for v3? Create legacy Git branch only for v1/v2?
from oc-twigextensions-plugin.
@vojtasvoboda I think the main problem was the String or Array Extension as they are sometimes (as I've read) not loaded by default or have other names now. I tried to manually define some "old" methods directly where some errors "not defined etc." occurred and it worked in the 3.x. But it was to exhausting to find all twig changes and badly put them in the file where they were needed so I downgraded oct. CMS.
from oc-twigextensions-plugin.
@vojtasvoboda releasing it as v2 should be fine.
But IMHO ocms should provide all default available filters by twig https://twig.symfony.com/doc/3.x/filters/index.html
which makes this plugin for most developers obsolete.
Maybe you should start an discussion with Sam about it. You can also take a look modules/cms/twig/Extension.php
to see how they implemented them.
from oc-twigextensions-plugin.
I've tried changing all namespaces from Twig_Extension_* to Twig\Extension*, but now it throws Class "Twig_Extension" not found
on plugins/vojtasvoboda/twigextensions/vendor/twig/extensions/lib/Twig/Extensions/Extension/Text.php
. There is a problem with Twig v2 vs Twig v3 as @TimFoerster mentioned.
So I set compatibility with Twig plugin just for October v1 and v2. October v3 stays untested for now.
from oc-twigextensions-plugin.
ocms 2/3 recevied some new twig methods/function with a new Carbon version. How about to abandoned this plugin for ocms3 and write a document with alternatives for each method? This should be less work compared to upgrading it to Twig 3.
For example mailto is implemented in ocms now:
{{ [email protected] | mailto }}
=> <a href="mailto: {{ html_email('[email protected]')|raw }}">[email protected]</a>
Or using Carbon 2
{{ post.published_at | localizeddate('medium', 'none', locale) }}
=> post.published_at.locale(locale).isoFormat('L')
from oc-twigextensions-plugin.
I actually would like to do a version of this plugin for OC v3.x. Or is already somebody else into it?
But with my limited PHP knowledge, I have some question. Maybe I would achieve it with some help.
So, I had a look at modules/cms/twig/Extension.php
and thought, that like following it should work. I thought, I do just the uppercase filter as a start and later add all others, when I know, how to do it.
This is the boot method in Plugin.php:
public function boot()
{
// init Twig
$twig = $this->app->make('twig.environment');
// add new twig extensions
$twig->addExtension(new OcTwigExtension());
}
Then I created a new class OcTwigExtension:
class OcTwigExtension extends TwigExtension
{
/**
* getFunctions returns a list of functions to add to the existing list.
* @return array
*/
public function getFunctions()
{
return [
new TwigSimpleFunction('uppercase', [$this, 'uppercaseFunction'], ['is_safe' => ['html']]),
];
}
/**
* uppercaseFunction converts text uppercase.
* @return bool
*/
public function uppercaseFunction($string)
{
return (string) mb_convert_case($string, MB_CASE_UPPER, "UTF-8");
}
}
But the uppercase filter seems to be unknown like this.
from oc-twigextensions-plugin.
Hello, most of this functionality is now included in the core. See issue #72 for details.
from oc-twigextensions-plugin.
Related Issues (20)
- Translations sets days months and year with value 1 HOT 1
- base64_encode/decode (enhancement) HOT 1
- Having trouble with the Arabic language HOT 6
- Custom plugin and custom lang.php file HOT 1
- ucfirst filter has wrong behavior.
- Plugin update error HOT 2
- Group By function? HOT 5
- Class 'Twig_Extensions_Extension_Text' not found with OctoberCMS v1.1.1 HOT 5
- Plugin prevents password retrieval HOT 1
- mode-js.js for October plugin - Twig Extensions (I think) HOT 1
- "Target class [twig.environment] does not exist" while running phpunit HOT 1
- New version won't update HOT 9
- october 3.x HOT 3
- Struggling to update to latest version HOT 7
- October CMS v3.1 - Upgrade Guide HOT 5
- Incompatible with October v3.0 HOT 4
- Class "IntlDateFormatter" not found HOT 9
- Error with format_datetime() HOT 9
- Unknown "truncate" filter. HOT 3
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 oc-twigextensions-plugin.