STAR(3) Linux User Manuals STAR(3)

star - Simple Templates And Renderer, is a HTML template engine for PHP.

include 'star.php';

function star_render_template($templatename, $ctx=array(), $templatesbase=NULL, $cachedir=NULL)

star is a simple procedural template engine for PHP 7.3+ which is contained within a single file, and can be pasted onto the end of existing scripts. It supports Twig-style inheritance, variables, includes, and conditionals. It escapes output to protect against XSS attacks.

{% for product in products %}

{% if product.price > 50 %}
Expensive product:
{% else %}
Cheap product: {{ product.name }}
{% endif %}
{% endfor %}

<?php
require 'star.php';
$ctx = [
'page_title' => 'Product Catalog',
'user' => [
'name' => 'Alice',
'is_admin' => true
],
'products' => [
['name' => 'Laptop', 'price' => 999.99],
['name' => 'Mouse', 'price' => 24.99],
['name' => 'Keyboard', 'price' => 79.99]
]
];
echo star_render_template('test.tpl', $ctx, TPLDIR, TPLCACHE);

This loads the template file test.tpl and loads the context $ctx into it. The template is rendered, compiled, cached, and then emitted as HTML.

php(1), star(7) star documentation, usage and template syntax

Ron Guerin <ron@vnetworx.net>
star can be found at https://gothamcode.com/star and bugs/patches can be submitted by email.

2025-11-17 November 2025