phpnomad / template
Requires (Dev)
- phpnomad/tests: ^0.1.0
This package is auto-updated.
Last update: 2026-04-15 06:15:09 UTC
README
phpnomad/template is the template rendering abstraction for PHPNomad applications. It defines a small set of interfaces that describe how a template name becomes rendered output, without committing to any particular template engine. The primary contract is CanRender, which takes a template path and a data array and returns a string. Companion interfaces handle path and URL resolution, and a screen resolver interface covers admin routing for plugins that need it. A plain-PHP engine ships with the package, and phpnomad/twig-integration provides a Twig-backed implementation that slots into the same contract.
Installation
composer require phpnomad/template
Overview
CanRenderdefines the render contract: a template path plus a data array returns a rendered string, or throwsTemplateExceptionif something goes wrong.CanResolvePathsandCanResolveUrlsmap a logical template name to a file path or a public URL, keeping callers free of filesystem assumptions.ScreenResolverStrategycovers admin and page-slug routing, including current-screen detection and URL generation for slug and action pairs.RenderServicecomposes a path resolver with aCanRenderimplementation so application code passes a template name rather than an absolute file path.PhpEngineis the bundled default renderer. It appends.phpto the resolved path, extracts the data array into scope, and captures the include through output buffering.
Documentation
Full documentation lives at phpnomad.com, including how phpnomad/core exposes a Template facade for static access to the render service inside a running application.
License
Released under the MIT license. See LICENSE.txt.