Renderers are optional addon modules for Wireframe, used whenever you want to render view files authored in something other than PHP — typically in some sort of a templating language.

Noun. renderer (plural renderers) One who, or that which, renders.

Just like ProcessWire itself, out of the box Wireframe expects view files (views, component views, partials, and layouts) to be authored as a mixture of PHP, HTML, and whatever else you might want to display in the front-end. If you'd like to use a templating engine — such as Twig, Latte, or Smarty — instead, what you'll need to pull it off is a renderer module.

Renderer support was added in Wireframe 0.9.0.

Enabling a renderer

Enabling a renderer is actually quite simple. First of all, you need to install both Wireframe and a renderer module – such as Wireframe Renderer Twig – and then set up Wireframe. Once that's done, you can open the bootstrap file (wireframe.php) and instruct Wireframe to use a specific renderer:

// during Wireframe init (this is the preferred way):
    'renderer' => ['WireframeRendererTwig', [
        // optional settings array

// ... or after init (this incurs a slight overhead):
$wireframe->setRenderer('WireframeRendererTwig', [
    // optional settings array

In the examples above we're defining renderer for the entire Wireframe framework. It's also possible to enable a specific renderer for the View – at any given point of program execution – or even to a single Component class. (Such cases are probably rare, but this option exists in case you happen to need it.)

Automatic fallback to PHP files

In case a suitable file for the renderer – which, for an example, could be default.twig for the Twig renderer rendering the default view of a template or component, or the default layout for that matter – Wireframe will automatically check if it can find a PHP file of the same name (default.php), and use that instead.

This fallback behaviour is intentional, and comes with a couple of benefits:

Back to top