You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Construct the View$pugView = newPugRenderer('./path/to/templates', [
'option' => 'foobar',
]);
//Render a Template$response = $pugView->render(newResponse(), '/path/to/template.pug', $yourData);
Template Variables
You can add variables to your renderer that will be available to all templates you render.
// via the constructor$templateVariables = [
'title' => 'Title',
];
$pugView = newPugRenderer('./path/to/templates', [], $templateVariables);
// or setter$pugView->setAttributes($templateVariables);
// or individually$pugView->addAttribute($key, $value);
Data passed in via ->render() takes precedence over attributes.
$templateVariables = [
'title' => 'Title',
];
$pugView = newPhpRenderer('./path/to/templates', $templateVariables);
//...$pugView->render($response, $template, [
'title' => 'My Title',
]);
// In the view above, the $title will be "My Title" and not "Title"
By default, pug-php is used.
But you can specify an other engine:
PS: Phug is automatically installed with default install since Pug-php 3
use it internally. But you can also install different renderer engine,
for example tale-pug: