europaphp / skeleton

A feather-weight, extremely-fast, diverse, scalable and productive PHP 5.4 View Controller framework.
17 stars 9 forks source link

Template system - Integrate Twig #61

Open Maxwell2022 opened 13 years ago

Maxwell2022 commented 13 years ago

I think it would be a good idea to integrate twig as the template system. I used twig at work for few days and love it. The way you can extends template and overwrite blocks is awesome.

treshugart commented 13 years ago

I think that's a great idea and have been wanting to do it for awhile. It should be doable by extending Europa\View\ViewScriptAbstract.

Would you be able to take this on?

treshugart commented 13 years ago

Also, check to see if we can integrate the current helper system into Twig. It would be a good way for us to extend the twig component via helpers.

Maxwell2022 commented 13 years ago

I don't think we can't re-use the actual helper into twig without creating new parser for twig.

treshugart commented 13 years ago

Then just implement the ViewScriptInterface instead of the ViewScriptAbstract.

Maxwell2022 commented 13 years ago

I have a problem with the render method. It's declared differently in Twig and Europa. I've create a new branch 2.0_Twig, you can have a look if you want.

I've created a new view Europa\View\Twig that extends Twig_Environment and implement ViewScriptInterface If I remove the interface the controller can't set the view because it's not an instance of Europa\ViewInterface

I'm still investigating how I can do...

treshugart commented 13 years ago

I'll see if I can have a look tomorrow night.

On 30/10/2011, at 19:50, Maximereply@reply.github.com wrote:

I have a problem with the render method. It's declared differently in Twig and Europa. I've create a new branch 2.0_Twig, you can have a look if you want.

I've created a new view Europa\View\Twig that extends Twig_Environment and implement ViewScriptInterface If I remove the interface the controller can't set the view because it's not an instance of Europa\ViewInterface

I'm still investigating how I can do...

Reply to this email directly or view it on GitHub: https://github.com/treshugart/EuropaPHP/issues/61#issuecomment-2568739

treshugart commented 13 years ago

I ended up just having a look now. Love my iPad!

Why don't you just pass the Twig_Environment to the constructor? Then you don't have to worry about implementation conflicts and it's easier to configure.

On 30/10/2011, at 19:50, Maximereply@reply.github.com wrote:

I have a problem with the render method. It's declared differently in Twig and Europa. I've create a new branch 2.0_Twig, you can have a look if you want.

I've created a new view Europa\View\Twig that extends Twig_Environment and implement ViewScriptInterface If I remove the interface the controller can't set the view because it's not an instance of Europa\ViewInterface

I'm still investigating how I can do...

Reply to this email directly or view it on GitHub: https://github.com/treshugart/EuropaPHP/issues/61#issuecomment-2568739

Maxwell2022 commented 13 years ago

I've update the branch with something that partially work. I manage the render Twig templates but the helper are not woking for now. Also I got confuse with the path locator, if you want to have a look. For now I've hardcoded the one in the Europa\View\Twig I guess we can do something for that.

I found that adding path the the view locator was not woking properly because the locator was finding the index.php before the index.php.twig Either we have the setup each view with its own locator in the bootstrap or find another way to locate the files. Using the file system loader from twig we have to specify a relative path to the file system setup in the constructor.

Also I had to comment the error handler in the index.php. It's not handling error correctly. It's trying to execute the last action requested (ie. get(), post()...) but can't find it in the error class.

That's it for today ;)

treshugart commented 13 years ago

You can tell the locator to look for a different extension. You won't have very many situations where someone will want to use the PHP and twig views in the same system.

Error class should use __call() to capture all method types.

On 31/10/2011, at 22:12, Maximereply@reply.github.com wrote:

I've update the branch with something that partially work. I manage the render Twig templates but the helper are not woking for now. Also I got confuse with the path locator, if you want to have a look. For now I've hardcoded the one in the Europa\View\Twig I guess we can do something for that.

I found that adding path the the view locator was not woking properly because the locator was finding the index.php before the index.php.twig Either we have the setup each view with its own locator in the bootstrap or find another way to locate the files. Using the file system loader from twig we have to specify a relative path to the file system setup in the constructor.

Also I had to comment the error handler in the index.php. It's not handling error correctly. It's trying to execute the last action requested (ie. get(), post()...) but can't find it in the error class.

That's it for today ;)

Reply to this email directly or view it on GitHub: https://github.com/treshugart/EuropaPHP/issues/61#issuecomment-2575636

treshugart commented 13 years ago

What I am thinking about doing with this is moving a lot of the functionality from ViewScriptAbstract to Php. This will allow us to extend the abstract view easier and make the interface easier to implement.

For example, if we move render, renderScrip, all of the extend/parent/child and helper functionality to the Php view, then there is less to worry about in the abstract view. We can then require that only require that 1 method is implemented, renderScript.

Maxwell2022 commented 13 years ago

I had to modify the locator to offer the possibility to return the relative path of a script instead of the full path. I've also added a method getPaths() with return the paths of the locator (in an array).

I'm still investigating how to use the Europa helpler in twig.

treshugart commented 13 years ago

Don't worry about the helper it's too much. Helpers are fairly specific to the Php view. It would be nice, but if it's to much work or requires too much customization it's probably not worth it.

I'm currently editing the 2.0_Twig branch. See if you agree with what I've done after I push.

On Tue, Nov 1, 2011 at 8:25 PM, Maxime < reply@reply.github.com>wrote:

I had to modify the locator to offer the possibility to return the relative path of a script instead of the full path. I've also added a method getPaths() with return the paths of the locator (in an array).

I'm still investigating how to use the Europa helpler in twig.

Reply to this email directly or view it on GitHub: https://github.com/treshugart/EuropaPHP/issues/61#issuecomment-2588282

T

Maxwell2022 commented 13 years ago

ok, waiting for your update so ;)

treshugart commented 13 years ago

Just pushed. Let me know what you think. All that the user needs to make sure they do is pass a \Twig_Environment to \Europa\View\Twig::__construct() and set an alternate suffix if they're not going to use the default ".twig" suffix.

Subject to change :)

On Tue, Nov 1, 2011 at 8:47 PM, Maxime < reply@reply.github.com>wrote:

ok, waiting for your update so ;)

Reply to this email directly or view it on GitHub: https://github.com/treshugart/EuropaPHP/issues/61#issuecomment-2588434

T

treshugart commented 12 years ago

Since JavaScript only front-ends are becoming the norm and they are easier to maintain and build, this is being pushed to 2.1.0 to give us time to evaluate whether or not it's actually worth it. PHP views and helpser are still supported, however, they may not exist in a future version.

treshugart commented 11 years ago

Since releasing 2.0.0, this would best be implemented using a module and put into packagist.