Download the PHP package wackowiki/templatest without Composer

On this page you can find all versions of the php package wackowiki/templatest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package templatest

Templatest

Push-style (with pull methods for e.g. csrf & i18n) lazy topo-ordered incremental building, liberated from von-neumann-style applicative transition template engine for WackoWiki.

Templatest is a lightweight, compiled template engine that separates presentation from logic. Templates are compiled once into an internal AST of patterns, variables, subpatterns and filters, then rendered by walking the AST and applying transformations on demand.

Features

Requirements

Installation

Or, if vendoring manually:

Quick start

Template file hello.tpl

(Use [==== name ====] for visual emphasis — Templatest accepts any number of = signs.)

Rendering

Output

Template syntax

Quote convention

Templatest tags are wrapped in ' (apostrophe) characters. You can use one or more quotes on each side — the parser treats them as visual delimiters only. The minimum is one:

For nesting clarity, it's common to use more quotes for outer context and fewer for inner context, though this is purely cosmetic:

Equal signs in pattern markers

Pattern blocks use [= name =] or [==== name ====] — any number of = signs works:

All three are equivalent. Use whichever reads best.

Pattern definition

The first pattern defined in a file is the main pattern and is the one rendered by default.

Inline (one-off) pattern

Useful for small reusable chunks. The name may be a single punctuation character (anonymous) or an identifier.

Variables

Variables are assigned from PHP via $tpl->var_name = 'value' or via underscore-split paths.

Subpatterns

Embeds a pattern instance. Each invocation instantiates a fresh copy unless static inlining applies.

Pull actions

Invokes a user-registered PHP callback. The callback receives:

Filter pipes

Filters are evaluated left-to-right. The result of each filter is the input to the next.

Setup directives

Built-in filters

Filter Alias Description
escape e HTML-escape value (modes: html, js, css, url, html_attr, raw)
default Use fallback when value is null/false
format sprintf() the value
stringify Convert any value to a readable string
date Format a Unix timestamp
join Implode an array with a glue
lower mb_strtolower
upper mb_strtoupper
number number_format with custom decimal/thousands separators
void Drop the value (returns null)
index Drill into nested arrays via dot-notation path (or var.path sugar)
replace Sequential str_replace pairs
json_encode Encode value as JSON, optional flags
json_decode Decode JSON string
sp2nbsp Convert runs of spaces to non-breaking spaces
spaceless Strip whitespace between HTML tags (preserves <pre>, <textarea>)
regex preg_replace; strict mode returns null on no match
trim trim with custom character mask
url_encode URL-encode a scalar or encode an array as query string
striptags Strip HTML tags with optional allow-list
nl2br Convert double newlines to <p> blocks
truncate Truncate to a length with ellipsis
split Explode or str_split depending on delimiter
list Pick one of N arguments by index
enclose Wrap with prefix and postfix strings
check Render a checkbox <input> value/checked pair
checkbox Render checked attribute if truthy
select Render selected attribute if matches
pre Mark next output as preformatted (no auto-indent)

API reference

Templatest::read(string $filename, ?string $cache_dir = null): TemplatestUser

Compiles (or loads from cache) the template and returns a renderable instance.

TemplatestUser

Magic __set

The single-segment form ($tpl->name = ...) sets a top-level variable. The underscore form walks the pattern tree, so $tpl->items_item_text is equivalent to $tpl->set('items', 'item', 'text', value).

Magic __get

Returns the set-count for the chroot-prefixed variable name. Returns int, not an object — chained property access ($tpl->items->item->text) does NOT work; use the underscore-split form for both reading and writing.

Chroot context

Pull functions

Clone by pattern name

Direct invocation

set()

TemplatestEscaper

Context-aware escaping utilities, exposed via the escape filter:

Caching

Compiled templates are cached to disk if a $cache_dir is provided. The cache is invalidated when:

To disable caching for a single file, set its write bit off (chmod 644); Templatest will re-read from source each time.

To clear the entire cache:

Configuration

Setup directives (in .tpl files)

Default escape modes

TemplatestSetter::ESCAPER constant controls the default when a pattern has no explicit .escape directive. Default is 'raw' (no escaping).

Testing

Run with testdox formatting:

Run a single test:

Generate coverage (requires pcov or xdebug):

Architecture

Compilation pipeline

Render pipeline

Standalone helper utilities (Helper class)

Methods used internally that may also be useful on their own:

Credits

License

BSD-3-Clause — see LICENSE file.


All versions of templatest with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wackowiki/templatest contains the following files

Loading the files please wait ...