Syntax Comparison
Side-by-side code comparisons: Tplix tag syntax vs PHP. See how Tplix reduces template syntax by up to 72%, eliminates delimiter confusion, and makes templates readable for designers and developers alike.
Template Syntax: Tplix vs PHP
PHP is powerful for application logic — but embedding its syntax directly into HTML creates noise, confusion, and fragile templates. Tplix replaces PHP statements with a clean, minimal tag-based syntax that anyone can read and maintain, no PHP knowledge required.
Displaying a Variable
Array Access
Foreach Loop
Real-World: Mixed With HTML Tags
Most telling exampleempty() check. Tplix's {foreachelse} handles it cleanly.
A note on PHP short-tags
The examples above use PHP short-tag syntax (<?=$foo?>) as a shortcut for <?php echo $foo; ?>. Many developers avoid short-tags entirely since they are optional and not guaranteed across all server configurations. Let's compare the full syntax instead:
Long PHP Syntax Mixed With HTML
Delimiter Confusion
PHP tags share the < > characters of HTML tags. Mixed inside HTML markup, <?php ?> tags become genuinely difficult to distinguish from HTML elements at a glance — especially in a large template file. This blurs the boundary between application logic and presentation.
<?php and <div> look nearly identical at a glance in a large template
Any PHP can be injected directly into templates — no boundary between logic and presentation
{tags} Fix ThisCurly-brace syntax is visually distinct from HTML — impossible to confuse with an HTML tag
Simplified Logic
Tplix features human-readable logic statements. The following examples show the difference side by side.
Printing odd numbers 1–20
Table rows — new row every 4th item
Loops over $foo and starts a new table row after every 4th cell.
Output modifiers — lowercase and HTML-escape a variable
Notice the natural left-to-right flow in Tplix — it reads like a sentence.
lower and escape are built-in plugins. They're purpose-built for presentation output — not general-purpose PHP functions. Chainable, readable, and designer-friendly.
Syntax at a glance
| Task | PHP chars | Tplix chars | Saving |
|---|---|---|---|
| Variable output | 5 | 2 | 60% |
| Array access | 9 | 3 | 67% |
| Foreach loop | 18 | 5 | 72% |
| Real-world HTML block | ~306 | ~196 | 36% |
| Single echo (long syntax) | 19 | 6 | 69% |
Browse the full syntax reference in the documentation and try it on your own templates.