{$hello} or <?=$hello?>

Tagscript-style syntax vs. PHP syntax

Previous versions of ProcessWire, as well as the CMSs that preceded it (like Dictator CMS) used a tagging syntax where you could reference a value in your template using a tag like {$title}. Everywhere that appeared, it would be replaced by the page's title field. It went a lot further than that, but this is a simple example.

As time has gone on, I've come to question the value of this, as {$title} is equivalent to <?=$title?> in PHP syntax. In that case, the tagged version is slightly shorter, but at what cost? When you start to realize the redundancy and inefficiency of the tagged version, it starts to look a lot less attractive. Despite writing such template engines in the past, I always reverted back to PHP syntax for the direct simplicity, and efficiency of it. I didn't want to start down the road of creating a new syntax for people to learn. Especially when I knew I wouldn't use it myself. You don't need to know PHP in order to use its syntax in a template, and much of the PHP syntax you learn is universal and non-proprietary. Tagged syntax seems to be based largely upon a myth.

This becomes more significant as you start working with loops and branches, where the tagged syntax can become significantly more verbose. And then even more significant when you need to manipulate values before output, or work with more complex data types. What you end up with is something like the Smarty template engine... A new language to learn that is more complex than the language it was to replace (PHP).

In ProcessWire, I wanted to be sure that there was a high level of consistency, and lack of ambiguity in the API syntax. I didn't want to end up with a situation where sometimes you would use {$tags} and other times you would use PHP syntax. In my mind, that adds complexity and confusion. Add to that the overhead of another template engine, and I'm convinced that PHP itself is the best possible template engine. ProcessWire is designed with this in mind. That's not to say that we won't add some kind of tag-script for simple shortcuts in the future, but the template engine will always be PHP based.

Twitter updates

  • New post: In this week’s post, we’ll take a look a look at the new website and focus on some parts of it and how they were built. Then we’ll dive into the latest version of ProcessWire on the dev branch, version 3.0.124— More
    11 January 2019
  • New ProcessWire main site rebuild ready for preview— More
    4 January 2019
  • Happy Holidays! This latest master version of ProcessWire contains hundreds of new additions, fixes, optimizations and more. This post covers all the highlights— More
    21 December 2018

Latest news

  • ProcessWire Weekly #244
    In the 244th issue of ProcessWire Weekly we'll cover the latest core updates, introduce the new processwire.com site, ask a PHP version related question in the weekly poll, and showcase the site of an open source room bookings app. Read on!
    Weekly.pw / 12 January 2019
  • ProcessWire 3.0.124 and new website launched
    In this week’s post, we’ll take a look a look at the new website and focus on some parts of it and how they were built. Then we’ll dive into the latest version of ProcessWire on the dev branch, version 3.0.124.
    Blog / 11 January 2019
  • Subscribe to weekly ProcessWire news

“ProcessWire is like a breath of fresh air. So powerful yet simple to build with and customise, and web editors love it too.” —Margaret Chatwin, Web developer