Skip to content

usingjsonschema/ujs-format-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Message format utility

Build Status

Message formatting utility function. Using a message template containing replacement markers {#} (open brace # close brace), where # is a digit between 0 and 9. Each replacement marker will be replaced by its corresponding parameter passed to the function. For example,

var format = require ("ujs-format").format;
format ("Syntax error on line {0}: Missing '{1}'", "101", ")");

will generate the result string,

Syntax error on line 101: Missing ')'

Using this approach helps with message organization (isolating message text definitions from the code they are used in) and internationalization, as the message text can be substituted with different language text, and the replacement parameters adjusted accordingly.

Installation

The program can be installed using npm, with the command,

npm install ujs-format

Project

This program is part of the [Using JSON Schema] (http://usingjsonschema.github.io) project.

License

MIT

About

Simple message formatting utility for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published