#Tags.js ####Minimalist [Mustache]/[Handlebars] style tag replacement for simple strings.
Include tag.js in your HTML file; tag.js has no dependencies. Tag.js is incredibly lightweight (<1kb) and efficient.
<script src="tags.js"></script>
#####Simple
var tags = {
firstName: "John",
lastName: "Smith"
};
var content = "Welcome {{firstName}} {{lastName}}.";
var message = Tags.get(content, tags); //"Welcome John Smith."
By default, Tags.js will remove all tags even if a matching value is not provided. Mustache and Handlebars function in the same manner. This behavior can be changed by disabling tag stripping.
#####Tag stripping enabled (default)
var tags = {
lastName: "Smith"
};
var content = "Welcome {{first}} {{lastName}}.";
var message = Tags.get(content, tags); //"Welcome Smith."
#####Tag stripping disabled
var tags = {
lastName: "Smith"
};
var content = "Welcome {{first}} {{lastName}}.";
var message = Tags.get(content, tags, false); //"Welcome {{first}} Smith."
Tag.js does not escape strings like [Mustache] and [Handlebars]. This library is designed for tag replacement on simple strings such as paths and phases. For a complete template solution see [Mustache] or [Handlebars].
Tags.js has been tested in all modern browsers and Internet Explorer 7+.
Released under [MIT License]. [MIT License]: http://mit-license.org/ [Mustache]: http://mustache.github.io/ [Handlebars]: http://handlebarsjs.com/