phproberto / joomla-twig Goto Github PK
View Code? Open in Web Editor NEWTwig 2.0 & Twig extensions integration for Joomla! https://phproberto.github.io/joomla-twig/
License: Other
Twig 2.0 & Twig extensions integration for Joomla! https://phproberto.github.io/joomla-twig/
License: Other
So the output markup does not contain any white space. Dimitris said that Gzip encoding/decoding consumes timd. Check alternatives like:
User reported this:
I wanted to give you some feedback on something I found when first trying to use Joomla-twig.
On the main github page under Installation it says you can do this to view an example:
JLoader::import('twig.library');
echo Twig::render('@library/twig/examples.html.twig');
When I tried this I received an error because dump() couldn’t be found. I had to use this code to get the example to work:
JLoader::import('twig.library');
$twig = Twig::instance();
$twig->environment()->addExtension(new Twig_Extension_Debug());
$twig->environment()->enableDebug();
echo Twig::render('@library/twig/layouts/examples.html.twig');
After I had that working I had a lot more confidence in using your project.
Add information about how to use debug and how it works in default mode.
with this simple code :
JLoader::import('twig.library');
echo Twig::render('@component/com_allevents/events/agenda.twig');
I obtain :
Warning: count(): Parameter must be an array or an object that implements Countable in /home/alleve87/public_html/plugins/system/gantry/gantry.php on line 406
Error: Argument 1 passed to Gantry\Component\Twig\TwigNodeTry::__construct() must be an instance of Twig_NodeInterface, instance of Twig_Node given, called in /home/alleve87/public_html/libraries/gantry5/classes/Gantry/Component/Twig/TokenParserTry.php on line 49: Argument 1 passed to Gantry\Component\Twig\TwigNodeTry::__construct() must be an instance of Twig_NodeInterface, instance of Twig_Node given, called in /home/alleve87/public_html/libraries/gantry5/classes/Gantry/Component/Twig/TokenParserTry.php on line 49
Of course I use a Gantry template :)
Do you have any idea ?
Create a License link in sidebar menu.
Check if it makes sense to provide a jform function to load a form
Hi
For anyone suffering.
If you update to PHP7.4 twig like:
{{ something }} {{ else }}
will become "somethingelse" instead of expected "something else"
solution:
update twig to 2.14.4
go to extensions/libraries/composer.json
update require twig version to
..
"twig/twig": "~2.14.4",
..
run "composer update" in library folder
..nightmare is gone.. I mean partially
So we have a real fair comparispn
Main ideas:
use Phproberto\Joomla\Twig\Traits\ViewTwigRenderer;
getLayoutData()
.getLayoutData()
(which is also a good practice) and override the loadTemplate logic so it doesn't need any extra changes by users.Example com_users/views/login/tmpl/default.php
content would be something like:
echo Twig::render('@component/com_users/login/default.html.twig', $this->layoutData);
So if user has an override the legacy rendering will be used.
Maybe a pure twig rendering + a legacy mode.... play with it.
Add to docs the ways developers can integrate joomla-twig in their extensions.
Is it possible to include an article into a template and also have the article scanned for any twig fields?
Or is it possible to render from a string?
Hi,
I've been struggeling with this for a while.
I'm used to Twig and its inheritance thru blocks outside of this Joomla enviroment.
But the blocks in joomla has no power over the joomla native inheritance in many cases.
In a nutshell:
Say we have index.php in the template root where the $this includes many data but the article content which is available in the <jdoc:include type="component" /> and not in its parent view.
specifically:
the index.php loads a article.html.twig that extends base.html.twig..
The article.html.twig is populated by needed data from the index php like so:
$data = array(
'sitename' => htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8'),
'site_url' => JUri::base(),
..
That is all fine we can play with the data we prepared in the main index.php
The data by the Joomla nature does not have the article data yet. They are loaded as part of the "component". One might think we can make a block placeholder and fill it up from the child component view. But that does not work here.
It is a bit of a problem as if we for example want to load extra_fields from the com_k2 outside its own view we are out of luck.. or at least I am. As I still heaven't found how to send share data from child view to parent view.
It would be awesome to have something like jmodule_get_module for components. That will allow us to get the component data as such and play with the dat in their raw form anyway we like in any time and place we like.
Hope I'm understood a bit.
Hello,
Is it possible extends, and macros?
https://twig.symfony.com/doc/2.x/tags/extends.html
Coz I can't find a way how to.
I basically do not know where is the default path set where from it takes if it does other twig files such as parent layouts, macros and the like.
thank you, Jan
Hi! I've just installed the latest package of the plugin in Joomla. I followed the instruction for testing but I received this error message:
Class 'Twig\Loader\ChainLoader' not found
I've checked in all files and i cannot find any class named ChainLoader. Could a file could be missing in the package ?
Thank you!
To ensure that nobody is able to install joomla-twig when php version <7.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.