DooPHP IRC channel


it there any Twig integration solution for Doo?

This is for general DooPHP discussion. Ask your questions here.

it there any Twig integration solution for Doo?

Postby img » Mon Oct 24, 2011 11:54 am

I love Twig at first sight :P

Twig:
http://twig.sensiolabs.org/documentation


The performance is really good (in fact, according to author, TWIG is faster than all other PHP templating engines) and it is easy for our HTML integrators to learn the language.


is there anyone would share a Twig integration solution ?

thanks a lot!!
img
 
Posts: 76
Joined: Fri Dec 11, 2009 5:10 am

Re: it there any Twig integration solution for Doo?

Postby RichardM » Thu Nov 03, 2011 2:23 pm

Hi,

I did look at doing this very early on with DooPHP (talking about 2 years ago now) and I don't have any code to offer up to hand.

However, from what I recall I pretty much did the following:
1) Setup a base controller for my app (extending DooController) which all my other controllers would then extend
2) In the base controllers constructor I initialised Twig's template engine using the code from there samples
3) Added a new render method say renderViewWithTwig($view)
4) Added a couple of utility functions etc to set values to be made available within the Twig templates
5) extended the base controller and called the renderViewWithTwig method

As for the code to go inside the functions I mainly chopped it out of the Twig sample code. It didn't make full use of the template engine but I suspect with some more work one could add it in. Alternatively you could create your own View class and use this like the DooView and DooViewBasic classes but a DooViewTwig


Richard
Note: code samples my not be 100% accurate.
RichardM
 
Posts: 1329
Joined: Sun Aug 30, 2009 6:03 pm
Location: Cumbria, UK

Re: it there any Twig integration solution for Doo?

Postby img » Tue Jul 10, 2012 9:51 am

RichardM wrote:Hi,

I did look at doing this very early on with DooPHP (talking about 2 years ago now) and I don't have any code to offer up to hand.

However, from what I recall I pretty much did the following:
1) Setup a base controller for my app (extending DooController) which all my other controllers would then extend
2) In the base controllers constructor I initialised Twig's template engine using the code from there samples
3) Added a new render method say renderViewWithTwig($view)
4) Added a couple of utility functions etc to set values to be made available within the Twig templates
5) extended the base controller and called the renderViewWithTwig method

As for the code to go inside the functions I mainly chopped it out of the Twig sample code. It didn't make full use of the template engine but I suspect with some more work one could add it in. Alternatively you could create your own View class and use this like the DooView and DooViewBasic classes but a DooViewTwig


Richard



A very late thanks!

I got it done and looks fine for now.

thank you Richard.
img
 
Posts: 76
Joined: Fri Dec 11, 2009 5:10 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron