A Mustache wrap to render only perfect Mustache templates.
Aka, monitor exceptions and missing variables.
composer require ssitu/nietzsche
Will also require SSITU/Blueprints
FlexLogsTrait
andFlexLogsInterface
specifically.
This is a Psr-3 "logger aware" implementation with a fallback.
If no use of other SSITU blueprints, you can download just those two files.
And, well, you will need Mustache too.
use SSITU\Nietzsche\Nietzsche;
require_once '/path/to/vendor/autoload.php';
$Nietzsche = new Nietzsche();
# optional:
$Nietzsche->setLogger($somePsr3Logger);
# alternatively, you can retrieve logs that way:
$Nietzsche->getLocalLogs();
// if no logger set: returns all logs history;
// else: only last entry
$v_ = ["planet"=>"world"]; #could also be an object, as specified by Mustache doc
$viewName = "hello";
$viewDir = "path/to/views/";
$mustacheOpts = []; # cf. Mustache doc
// will either render your template,
// or false if something went wrong --like a missing variable
$Nietzsche->renderPerfectMustache($v_, $viewName, $viewDir, $mustacheOpts);
Sure! You can take a loot at CONTRIBUTING.
This project is under the MIT License; cf. LICENSE for details.