Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nette - global variables in Latte (https://quip.com/1DAjAVxx9gZ8)
// app/config/config.neon
parameters:
globals:
appVersion: v1.0.0
services:
nette.latteFactory:
class: App\LatteWithGlobalVariables
setup:
- addGlobals(%globals%)
<?php
namespace App;
use Latte\Engine;
class LatteWithGlobalVariables extends Engine
{
private $globals = [];
public function addGlobals(array $globals)
{
$this->globals = $globals;
}
public function render($name, array $params = array())
{
return parent::render($name, $params + $this->globals);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.