codeguy / php-the-right-way

An easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative tutorials around the Web

Home Page:https://www.phptherightway.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update Templating - Further Reading with better examples

daggerhart opened this issue · comments

Some of the current examples in the Template - Further Reading section are bad.

Specifically:

  • Roll Your Own Templating System in PHP is a very long article full of unworkable code that is terribly formatted. The article is practically unusable by anyone (as the comments show).
  • Getting Started With PHP Templating starts with an introduction to MVC, includes some light overview of existing templating engines, then devolves into a Twig tutorial significantly consisting of Twig documentation copied and pasted.
  • Templating Engines in PHP is missing a lot of code. Likely this was lost in some migration / update to their site's templating engine 😰

The remaining articles are all framework/library dependent:

  • An Introduction to Views & Templating in CodeIgniter - Codeigniter
  • Master Pages - Laravel w/ Blade (this one is better than the other framework-specifics, having a video is nice)
  • Working With Templates in Symfony 2 - Symfony w/ Twig
  • Writing Safer Templates - Brainy (this one is also better that the rest, in that it has some general information about how a templating engine provides a safer code base, but ultimately this is already covered in the PHPRightWay Templating section)

Ideally, this section provides three things:

  1. Good introductions to templating in general
  2. Advanced templating engine design
  3. Examples that are explicitly for popular templating engines

3rd item (Examples): This is basically covered in the Libraries section, but the first 2 are either missing or unusable.

1st item (Introduction): I've written a few blog posts on the "introduction to templating" topic, but I'm not sure I'm the person to be teaching this stuff. Here are my blog posts, which I think are good examples of what should be provided in this section as introductions:

Again, I don't know that my posts are the best possibly articles for this topic, just showing as examples of what I think should be provided in the Template - Further Reading section.

2nd item (Advanced engine design): This is the reason I'm here submitting this issue. I am very interested in learning more about "How to design a PHP Templating Engine", but have had a lot of trouble finding resources with practical examples. I've re-discovered the Roll Your Own Templating System in PHP article many times over the past few years, only to be continuously disappointed and frustrated. I've even tried copying the page source code to fix it into something legible, but that exercise only highlighted to me how poorly the article is written.

Though not 100% positive, I believe the topics covered by an advanced article would include these items:

  • Currying
  • Lexer
  • Tokenizer
  • Token Parser
  • Compiling & Caching the template

But maybe I'm wrong... I have no way to know without some clear examples.

Welcome to thoughts and feedback about this idea. Also, if anyone knows of better resources for introduction to templating or building a templating engine, I love to see them.

commented

:)

I want people to learn:

  1. What templating is;
  2. Why it is useful;
  3. What templating libraries are available;

Building a templating engine is out of scope. I think the current templating content is a bit longer than necessary and could be reduced to improve focus. New links to better resources also welcome.

Closing for inactivity.