8

I'm looking for a minimalist template system for javascript, ala John Resig's Javascript Micro Templating. The smaller the better, and if it's jquery based even better. Recommendations?

I tried John's micro-templating but ran into a few issues, wanted to see if there are more baked / better packaged solutions out there.

[Update] I tried Resig's Micro Templating again and it's working well for me. Would still like to hear about other alternatives if there are any.

3
  • 2
    What kind of issue? I have used it and it works great! Commented Mar 5, 2010 at 18:06
  • What kind of problems were you running in to? That one seems pretty clever and basic. What more do you need from it? Commented Mar 5, 2010 at 18:18
  • The issue was likely me setting it up / using it incorrectly (I was attempting to integrate it into a larger project). I'm about to try it stand-alone and if that goes well I'll try the integration again. Commented Mar 5, 2010 at 18:21

6 Answers 6

5

There is also Mustache.js, it has a neat syntax IMO.

Sign up to request clarification or add additional context in comments.

Comments

3

This one is good and tiny (400bytes gzipped or 600bytes minified). Also has the attractive {{hello}} syntax rather than the <?php hideous ?> <%whats-the-point-might-as-well-not-bother-with-templates%> syntax

https://github.com/jasonmoo/t.js

Slightly larger but still very good (personally only tested mustache):

https://github.com/janl/mustache.js

http://tempojs.com/

https://github.com/premasagar/tim (370 bytes for the 'tinytim' version)

Comments

1

Theres JBST

<a class="ExtLink"
            href="<%= "http://en.wikipedia.org/wiki/" + this.data.wiki %>"
            onclick="window.open(this.href);return false;"><%= this.data.name %></a>

Comments

1

JBST (JsonML+Browser-Side Templating) is a good alternative to John Resig's Micro Template. It has a similar syntax but template parsing is not performed at runtime so it can be more compact and robust. The result of parsing is pure JavaScript which can be combined with other scripts and executed directly in the browser.

UPDATE: this system was rewritten from the ground up as a duel-side template library (client & server) called DUEL: http://duelengine.org

Comments

0

I really like JST (JavaScript Templates). They use the same convention for tokens as JSPs ${} - pretty easy.

Comments

-3

In the end I went with John Resig's Micro Template, it's working nicely for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.