Templating
Canvas supports multiple templating engines through optional packages. Smarty is installed by default, but you can switch to Blade, Twig, Latte, or Plates depending on your preference — or use multiple engines side by side within the same application.
Installation
Each templating engine is available as a separate Composer package. Install the engine you want to use:
composer require quellabs/canvas-smarty
composer require quellabs/canvas-blade
composer require quellabs/canvas-twig
composer require quellabs/canvas-latte
composer require quellabs/canvas-plates
composer require quellabs/canvas-handlebars
Configuration
Set the active templating engine in config/app.php using the template_engine key. The value must match the package name of the installed engine:
// Template engine
'template_engine' => 'smarty', // default
Available Engine Identifiers
smarty— Smarty (default, installed with Canvas)blade— Laravel Blade syntaxtwig— Twig by Symfonylatte— Latte by Netteplates— Plates (native PHP templates)handlebars— Handlebars (compiled native PHP templates)
Engine-Specific Configuration
Each templating engine can be configured individually through its own config file in the config/ directory. These files are created automatically when you install the corresponding package:
config/smarty.phpconfig/blade.phpconfig/twig.phpconfig/latte.phpconfig/plates.phpconfig/handlebars.php
Use these files to configure engine-specific options such as caching, debug mode, template directories, and extensions — without touching the global config/app.php.
Mixing Engines via Dependency Injection
Canvas allows you to use multiple templating engines within the same application. Resolve a specific engine from the container using the for() method with the engine identifier:
$template = $container->for('smarty')->get(TemplateEngineInterface::class);
$template = $container->for('plates')->get(TemplateEngineInterface::class);
$template = $container->for('blade')->get(TemplateEngineInterface::class);
This is useful when migrating between engines incrementally, or when different parts of your application have different templating needs. Each resolved instance is fully configured and ready to render.