-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SmartyViewRenderer #29
Comments
Smarty like main or additional ViewRenderer? |
Additional. |
fooh, you reassured me |
We could use each renderer we want? |
Yes. One at a time with fallback to plain PHP. |
Why not choose renderer by file extension? |
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. |
@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'));
} |
@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. |
@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. |
@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. |
Maybe there could be a paramater like |
Will check what I can do with it... |
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. |
Basic implementation done. Also implemented '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',
),
),
), |
No description provided.
The text was updated successfully, but these errors were encountered: