Installation

Before you can make use of the templado engine, you need to add it to your project. The easiest way probably is to add it as a local, per-project dependency using Composer:

$ composer require templado/engine Using version ^2.2 for templado/engine ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 2 installs, 0 updates, 0 removals - Installing theseer/css2xpath (1.1.0) Loading from cache - Installing templado/engine (2.2.0) Loading from cache Writing lock file Generating autoload files

Alternatively you can of course also clone the source from the github repository. Keep in mind that you also need to manually clone the dependencies in that case.

Loading a base document

Before we can render anything with templado, we need to load the HTML document or snippet as our working base. The most convenient way for this is to use templado's abstraction layer:

<?php declare(strict_types = 1); use Templado\Engine\FileName; use Templado\Engine\Templado; $html = Templado::loadHtmlFile( new FileName('sample.xhtml') );

Templado does not require the file to contain a full HTML document. As internally DOM is used for parsing though, the file's content needs to comply to XML parsing rules. That means the file must not have more than one root element and HTML(5) documents need to use the XHTML(5) notation.

Once loaded, you are now ready to apply your first View Model, repopulate a form, embed >snippets, perform transformations and apply output filters.

To learn, how to do all this, you can read the in-depth documentation.