ssitu/nietzsche

A Mustache wrap to render only perfect Mustache templates. Aka, monitor exceptions and missing variables.

v0.9.0 2021-07-22 12:49 UTC

This package is auto-updated.

Last update: 2024-04-04 11:30:53 UTC


README

A Mustache wrap to render only perfect Mustache templates.
Aka, monitor exceptions and missing variables.

Getting Started

composer require ssitu/nietzsche

Will also require SSITU/Blueprints

  • FlexLogsTrait and
  • FlexLogsInterface 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.

How to

Init

use SSITU\Nietzsche\Nietzsche;

require_once '/path/to/vendor/autoload.php';
$Nietzsche = new Nietzsche();

Log

# 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

Run

$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);

Nietzsche Mustache

Contributing

Sure! You can take a loot at CONTRIBUTING.

License

This project is under the MIT License; cf. LICENSE for details.