Skip to content
The easiest string templating.
JavaScript
Find file
Latest commit c136e76 @felixexter init
Failed to load latest commit information.
.gitignore init
bower.json init
gulpfile.js init
package.json init
readme.md init
tmpl.js init
tmpl.min.js init

readme.md

tmpl.js

The easiest string templating.

Features

  • Easy data replacement in the string.
  • No dependency on jQuery.
  • Compatible with all browsers.
  • Nanoweight helper.

Use

Use keys in double brackets to replace your data.

Simple example

'These {{something}} are so {{adjective}}!'.tmpl({
    something: 'diamonds',
    adjective: 'shiny'
});

// These diamonds are so shiny!

With jQuery.ajax

var myTmpl = '...'; // Some template

$.ajax({
    url: 'path/to/data.json',
    success: function (data) {
        var tmpl = myTmpl.tmpl(data);
        $('#portfolio').append(tmpl);
    },
    error: function (data) {
        // Error
    }
})

License

Released under the MIT license.

Something went wrong with that request. Please try again.