Skip to content

Minimalist mustache/handlebar style tag replacement for simple strings.

License

Notifications You must be signed in to change notification settings

jasonlav/tags-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#Tags.js ####Minimalist [Mustache]/[Handlebars] style tag replacement for simple strings.

Installation

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>

Usage

#####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].

Compatibility

Tags.js has been tested in all modern browsers and Internet Explorer 7+.

License

Released under [MIT License]. [MIT License]: http://mit-license.org/ [Mustache]: http://mustache.github.io/ [Handlebars]: http://handlebarsjs.com/

About

Minimalist mustache/handlebar style tag replacement for simple strings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published