logging-helpers
Basic template helpers for printing messages out to the console. Useful for debugging context in templates. Should work with any template engine.
Install
Install with npm
npm i logging-helpers --save
Usage examples
Handlebars:
{{log "%s" "this is a message"}}
{{info "%s" "this is a message"}}
{{bold "%s" "this is a message"}}
{{warn "%s" "this is a message"}}
{{error "%s" "this is a message"}}
{{debug this}}
{{inspect foo.bar}}
Lo-Dash or Underscore:
<%%= log("%s", "this is a message") %>
<%%= info("%s", "this is a message") %>
<%%= bold("%s", "this is a message") %>
<%%= warn("%s", "this is a message") %>
<%%= error("%s", "this is a message") %>
<%%= debug(data) %>
<%%= inspect(foo.bar) %>
Verb (lo-dash, with special delimiters to avoid delimiter collision in documentation):
{%= log("%s", "this is a message") %}
{%= info("%s", "this is a message") %}
{%= bold("%s", "this is a message") %}
{%= warn("%s", "this is a message") %}
{%= error("%s", "this is a message") %}
{%= debug(data) %}
{%= inspect(foo.bar) %}
Register the helper
This should work with any engine, here are a few examples
template.helpers('logging-helpers', require('logging-helpers'));
assemble.helpers('logging-helpers', require('logging-helpers'));
verb.helpers('logging-helpers', require('logging-helpers'));
var handlebars = require('handlebars');
handlebars.registerHelper('logging-helpers', require('logging-helpers'));
Run tests
npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on December 11, 2014. To update, run npm i -g verb && verb
.