Welcome Guest, Not a member yet? Register   Sign In
template engine?
#11

(This post was last modified: 06-14-2016, 12:38 PM by PaulD. Edit Reason: added quote )

Quote:I am not a designer, but I got to hate writing PHP-views. :-) Although PHP is thought as a template language, as such it is a failure, I think.

Here is what I can say:

1. A specialized template language is needed, nevertheless how designers feel comfortable with PHP. Even, it could be partially portable outside PHP-systems.

2. CodeIgniter's policy about escaping has changed, escaping should be at output. A template engine with enabled by default HTML-escaping would give comfort in this situation. Otherwise it is not certain how carefully view's PHP code would be written. Built-in escaping for other contexts as HTML-attributes, JavaScript, etc. could be handy too.

3. A sophisticated template engine adds more value to programming than just arrangement relationships between programmers and designers. Seek for block-support, blocks could be defined in an abstract way and placed and moved wherever you like in your master template, a concrete controller can fill them with the concrete information.

A good template engine will allow you to clear your controllers from any visual design aspects - this is not achieved by me yet, due to maintaining BC, but it is achievable.

4. The CI3 built-in parser is quite minimalistic, it does not add significant value in comparison with the pure PHP-views. Better don't waste your time with it. Carefully pick up a third-party template engine and integrate it within your application.

Hi,

In comment to your points:

However php started, it is so much more than a template language now. That is like saying windows is just a way to access my files.

1. It might be needed, it might not. Some projects will benefit, others won't.

2. It may have changed. But I now see why data should be escaped on output. It makes alot of sense to me now.

3. Pure php gives the full power of php to views. A template engine will always have limited application of these things. However a template engine can offer block support, theming etc. but they all offer different benefits. Pre-defining a template engine in the framework would be wrong. Controllers are always free of design considerations, well at least mine are.

4. You are right. The built in template parser is not something I have actually ever used because of this. I think it should be deprecated in CI4.

Templating systems are so diverse and numerous, to be forced to use one like laravel does with twig, is in my opinion, verging on ridiculous. My framework of choice should not be telling me what templating system, shopping cart, file upload, forum, blog, authorisation method, database or image gallery I should use. That is up to me, surely, and my choice will not be the same as your choice for any of them.

CI does not do any of this to me, which I why I love using it.

Paul.
Reply
#12

@PaulD

4. Instead of total deprecation it could be a parser with "drivers", this Phil Sturgeon proposed long time ago. It is a good idea, I think. Template engines has different APIs, a generalization could be made and an uniform API could be provided by CodeIgniter. It would be nice template engine/PHP to be picked up at will, without the need for touching the controllers. Even better it would be if the needed template engine gets detected by the file extension of the loaded view - '.php', '.html.twig', '.blade.php', ...
Reply
#13

(This post was last modified: 06-15-2016, 05:31 AM by spjonez.)

ivantcholakov Wrote:3. A sophisticated template engine adds more value to programming than just arrangement relationships between programmers and designers. Seek for block-support, blocks could be defined in an abstract way and placed and moved wherever you like in your master template, a concrete controller can fill them with the concrete information.

This is my biggest gripe with CodeIgniter. A proper hot-swappable templating engine is the main feature I feel CI is lacking and could greatly benefit from.
Reply
#14

(This post was last modified: 06-15-2016, 05:44 AM by prezire.)

I agree with CI team's decision not to create a template engine. The parse() itself is enough when working with a designer. The view() method itself does the trick if the view file needs logic. Otherwise, the logic has to be done such as in the models and passed by the controller. All the template has to do is render what's being passed instead of creating its own logic. If logic really is needed in the view, then a more experienced designer leaning towards development is needed to go further with the development using the view() method.
Long live CodeIgniter!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB