Hotmess.js fast, tiny and powerful javascript templates
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Hotmess is a javascript templating engine focused on minimalism and performance.


  • Stupid fast!
  • Tiny! ~60 loc and <1kb minimized.
  • Use in the client and server.
  • Logic-less! With support for list iteration, "truthy" conditionals and default values.
  • Partials! Reuse templates and keep them concise.


Include the script in your page:

<script src="">

Creating and rendering a template is as simple as:

var tmpl = hotmess.compile("<p>I'm afraid I just {{color}} myself</p>");
document.body.innerHTML = tmpl( {color:"blue"} );


Variable tags render the named key from the current object/context. All variables are HTML escaped but can be rendered raw by prepending an {{& ampersand }}.


var data = {
  name: "Gob Bluth",
  job: "<b>magician</b>"
var out = hotmess.compile( "A {{&job}} never reveals his secrets! -{{name}}" )(data);


A <b>Magician</b> never reveals his secrets! -Gob Bluth

If a variable does not exist, nothing will be rendered unless you provide a default value. Surround default strings with quotes, or leave them off to name a different key as the default.


var tmpl = hotmess.compile( '{{yep}}, {{nope : "missing"}}, {{nope:meh}}' );
var out = tmpl({
  yep: "yep",
  meh: "well... ok"


yep, missing, well... ok


Arrays are iterated with the {{list}} tag. A plain {{}} tag closes the list and the inner template is repeated for each array element. The context in the inner template is set to each array element and is accessible with the {{.}} tag. Properties of the parent tag are accessed with the ../ prefix such as {{../parent_property}}.

First a simple example.


var tmpl = hotmess.compile( "{{~names}}{{.}} {{~}}" );
document.body.innerHTML = tmpl( { names: ["George", "Buster", "Lucille"] } );


George Buster Lucille

Now something more complex.


{{~ names}}
  <li style="{{ style() }}">{{name}} {{../surname}}</li>


  surname: "Bluth",
  names: [
    { name: "George", gender: "m" },
    { name: "Buster", gender: "m" },
    { name: "Lucille", gender: "f" }
  style: function(value, i) {
    // yep, you can call methods too
    var style = value.gender == "f" ? "color:pink;" : "color:blue;";
    // bold every other row
    if( i % 2 == 0 ){
      style += "font-weight:bold;";
    return style;


  <li style="color:blue;font-weight:bold;">George Bluth</li>
  <li style="color:blue;">Buster Bluth</li>
  <li style="color:pink;font-weight:bold;">Lucille Bluth</li>

####Empty Arrays

A conditional block for empty arrays may be supplied via the {{~^}} operator:

{{~ myArray}}if filled I repeat this{{~^}}if empty I print this{{~}}


Hotmess supports simple conditionals with the if {{? property}} if operator, elseif {{?^ property}} and else {{?^}} operators.

Syntax: {{? test}} test is truthy {{?^ elseIfTest}} elseIfTest is truthy {{?^}} else nothing was truthy {{?}}

You may also test for the false or missing values by adding the not ! symbol before the property name {{? !property}}

TODO: add more examples


Any template may be called from within another template. There are some caveats currently:

  • The partial template must be compiled and registered before the parent template is rendered.
  • No effort is made to prevent circular references, so infinite loops are possible.

Syntax: {{>partial}}

TODO: create examples


I hope to create some more rigorous benchmarks but for now I created a variant of the popular Javascript template language shootoff jsPerf.


I began this project to see how small and fast I could make a full featured template function. Hotmess is MIT Licensed and based on doT and Mustache.