Comments (15)
Smarty like main or additional ViewRenderer?
from yii2.
Additional.
from yii2.
fooh, you reassured me
from yii2.
We could use each renderer we want?
from yii2.
Yes. One at a time with fallback to plain PHP.
from yii2.
Yes. One at a time with fallback to plain PHP.
Why not choose renderer by file extension?
from yii2.
Just a note on choosing renderer by file extension; I've seen people needing to use a specific renderer even though the file extensions of their view files didn't match that renderer. I wouldn't think it's a good idea to lock it down to file suffix.
from yii2.
@rawtaz it's not using suffixes like in 1.1 anymore. In the controller you have to specify it explicitly:
public function actionSmarty()
{
echo $this->render('renderer.tpl', array('username' => 'Alex'));
}
from yii2.
@samdark Thank you for pointing that out. I think the thing I mentioned might still apply though, if the/which renderer to use would be decided by looking at the file suffix in the first argument to render.
from yii2.
@rawtaz nope. Renderer is an application component. There's no sense in using both Smarty and Twig in a single application so user will be able to configure one renderer at a time.
from yii2.
@samdark All I can say is that this was not the case for the user I was thinking about. I don't remember the specifics (can probably look it up if needed).
Regardless, why would there not possibly be circumstances where one needs to render views of different types? You could have for example a system that renderPartial()s some views from other systems, e.g. the system itself uses regular PHP views but it needs to renderPartial() Smarty or Twig views provided by some other party.
EDIT: And in relation to that, there might be cases where the view file to render doesn't have a file suffix that precisely matches the renderer's default.
from yii2.
Maybe there could be a paramater like cacheId
to specify the application component to be used as the renderer
from yii2.
Will check what I can do with it...
from yii2.
Renderer is no longer an application component, but a property of the "view" application component.
For needs like using multiple renderers simultaneously, you can create a wrapper renderer. Within this renderer you can write whatever logic in determining which render to use. We may consider providing such a wrapper renderer in the core which by default chooses view renderer by view file extension.
from yii2.
Basic implementation done. Also implemented CompositeViewRenderer
that allows using multiple renderers at once with the following config:
'components' => array(
'view' => array(
'class' => 'yii\base\View',
'renderer' => array(
'class' => 'yii\renderers\CompositeViewRenderer',
'renderers' => array(
'tpl' => array(
'class' => 'yii\renderers\SmartyViewRenderer',
),
'twig' => array(
'class' => 'yii\renderers\TwigViewRenderer',
),
),
// that's how to use only one renderer
//'class' => 'yii\renderers\TwigViewRenderer',
),
),
),
from yii2.
Related Issues (20)
- The model attributes validation do not use custom validator. HOT 3
- Small Change to yii.gridView.js please HOT 2
- queryOne keep loading and no result HOT 2
- Replace bower-asset with npm-asset HOT 2
- Yii::$app->request->post() empty result HOT 8
- yii\data\Sort::getAttributeOrders δΌε HOT 4
- CSRF can only be validated if in header HOT 4
- number field client validation does not work correctly HOT 5
- yii\rest\Serializer not works as expected HOT 3
- How can I give class for all of options tag in dropdown() of activefield ? HOT 1
- Can't upgrade to PHP 8.3 - ezyang/htmlpurifier HOT 2
- SQS issue with new AWS sdk HOT 2
- Implicit conversion from float in Formatter HOT 3
- AjaxValidation: ajax response with validation errors is not processed in 2.0.47 - 2.0.49.1 HOT 4
- ActiveReccord save, attributes issue HOT 3
- Missing BaseActiveRecord methods mentioned in documentation HOT 2
- add attribute on generated <script> tag HOT 3
- ActiveRecord::getRelation("????", false) throw ArgumentCountError exception HOT 1
- [Feature request] Yii gettext translations could support comments in PO files
- requires bower-asset/jquery HOT 1
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 yii2.