chalk-twig-filters

0.0.3 • Public • Published

Chalk Twig Filters

Build Status Coverage Status

Adds all configured chalk styles (sometimes referred to as themes) as twig.js filters.

Usage

Basic usage:

var Twig = require('twig');
require('chalk-twig-filters')(Twig);

That's it! Now you can use twig to render colored text for the console like so:

var Twig = require('twig');
require('./index')(Twig);
var someObject = {
  message: 'something wicked this way comes',
  date: new Date().getTime(),
};
var template = Twig.twig({data: '{{ date | date("m/d/Y h:m:s") | blue | underline}}: {{ message | cyan }}'});
console.log(template.render(someObject));

Advanced usage:

If you're doing anything clever like custom themes in chalk you can hand in the chalk instance to use. All styles should be automatically detected and filterified dynamically. All you have to do is hand in chalk as a second argument.

var Twig = require('twig');
var chalk = require('chalk');
// Configure chalk, add some theme combo, etc...
require('chalk-twig-filters')(Twig, chalk);

Dependencies (1)

Dev Dependencies (5)

Package Sidebar

Install

npm i chalk-twig-filters

Weekly Downloads

31

Version

0.0.3

License

GPL2+

Last publish

Collaborators

  • tizzo