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

(This post was last modified: 06-18-2020, 03:30 AM by Ceo.)

I think it would be a good idea for CI4 to come with a COMPILED template engine like Smarty or Twig

I know this idea has been brought up before and rejected.From what Ive gathered,  the main reason CI4 decided not to use a separate template engine was so as not to sacrifice performance and ease-of-use.


Here are some reasons I believe this is a good idea


  1. from my personal experience the view parser and Smarty syntax are quite similar. `{myVar}` vs ` {$myVar}`.Also, there are a lot more features in Smarty 
  2. According to CI, an advantage of using CI is promoting good coding practices but mixing php and html like is done in the CI4 docs is not a good coding practice
  3. A lot of developers already know Smarty or Twig and will prefer using them rather than relearning CI's mini template engine
  4. Smarty and Twig both support template inheritance which helps to properly manage templates
  5. Lastly and most importantly, a compiled template engine like Smarty is significantly faster than CI's view Parser.Yes I ran the test myself.The view parser took about 1600ms to render the CI4 default welcome message while Smarty took 1600ms initialy(after first compilation) then 900ms afterwards
It doesn't even have to be compulsory to use in CI4.It could be a Sytem module or a ThirdParty library.

Also, if this idea is accepted, I will help to implement it
Reply
#2

Hi Ceo,

If you wan't to build a module/plugin for CI4. Go for it! You don't need an approval from someone, only if it's being bundled with the system itself. As long as you make it into a Composer package, it will be easy for everyone to install and update.
Reply
#3

You might find this thread interesting.
Reply
#4

(06-18-2020, 06:32 PM)dave friend Wrote: You might find this thread interesting.
Yeah thanks.Ive seen that thread before.Before I posted my thread.That was why I decided to explain why it is a good idea
Reply
#5

(06-20-2020, 08:07 AM)Ceo Wrote:
(06-18-2020, 06:32 PM)dave friend Wrote: You might find this thread interesting.
Yeah thanks.Ive seen that thread before.Before I posted my thread.That was why I decided to explain why it is a good idea

I tend to agree with Jim's statement that "There is no single templating engine that would satisfy everyone"

However, I'm pretty sure if you developed and made available a wrapper for one or more compiled template systems you would find an audience. Make them known by posting links to the repo and/or Packagist page.
Reply
#6

(This post was last modified: 06-21-2020, 12:24 PM by ivantcholakov.)

https://github.com/ivantcholakov/starter...-edition-5

I am working on a more general way, but I am at a too early stage, unfortunately I altered some system files. The idea is a driver manager to detect/choose what template engine should be applied. Currently I have Twig (sort of working) and Markdown (which is a parser, actually), more maybe will come.

If you want to make a simpler integration of Twig for your purposes, feel free to grab code and to adapt it.

P.S.: A Composer package at this moment seems to me diffcult to be made, I don't intend to make one.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB