message
Javascript-based message lookup with support for message templates.
API Examples
JavaScript
var messages = ; ;
CoffeeScript
messages = require "messages" message "my-messages.yaml"then consolelog message "greeting"name: "World"
CLI Examples
$ message my-messages.yaml greeting --data 'name: World'
Hello World
The --data
flag is optional.
$ message my-messages.yaml farewell
Goodbye!
API
messages path
The message
module exports a single function that takes a path
and returns a promise. If the path is for a valid YAML file,
the promise resolves to an object whose properties are message helpers.
These helpers are: lookup
, message
, and abort
.
lookup key
Returns the message that corresponds to the key
.
message key, data={}
Returns the message that corresponds to the key
and
processes it as a template, using data
.
If you don't pass a data
argument, it defaults to
the empty object.
abort key, data={}
Works like message
except that it
displays the message on standard error and then aborts
(calls process.exit
) with a status code of 1.
Templates
Message uses Markup-JS to render template strings.