Re:Rendering on the Web
by krapp on Thursday August 22, 2019 @09:26AM
(#20767755)
>why do you need to implement a template system when the language you are implementing that template system can also function as a template system itself?
Because PHP, natively, doesn't provide the features that a modern template system needs to be safe, scalable or productive. PHP doesn't recognize HTML or XML as a type, or a "template" as a thing, automatically escape user supplied data (correctly, based on context) or correctly deduce content-type headers or route requests or any number of things one expects of a modern framework or templates. As a PHP application grows in complexity, you will, inevitably, find yourself reinventing frameworks. So might as well just use one that's already been proven in the wild and optimized.
All PHP has is string concatenation. It's "templating system" is blind string concatenation - that's it.
Because PHP, natively, doesn't provide the features that a modern template system needs to be safe, scalable or productive. PHP doesn't recognize HTML or XML as a type, or a "template" as a thing, automatically escape user supplied data (correctly, based on context) or correctly deduce content-type headers or route requests or any number of things one expects of a modern framework or templates. As a PHP application grows in complexity, you will, inevitably, find yourself reinventing frameworks. So might as well just use one that's already been proven in the wild and optimized.
All PHP has is string concatenation. It's "templating system" is blind string concatenation - that's it.