Frequently Asked Questions

Sam D edited this page May 4, 2015 · 20 revisions

What problems Transparency solves?

Transparency is mainly used as a client-side templating solution. A common use case could be where a web browser fetches JSON data via AJAX and renders dynamic parts of a page depending on this data.

Transparency can be used on a server-side with Node.js.

Why should I use Transparency and DOM based templating?

  • Javascript is a powerful language. Why use anything less for the template logic? No need to learn yet another microlanguage.
  • Transparency templates are valid HTML and play nice with other tools.
  • Transparency templates do not need to be compiled and do not contribute to page load latency
  • Transparency's method of operating on DOM nodes is faster than strings and innerHTML
  • Micro Templates Are Dead

Where can I contact developers for further support?


How fast is it?

Transparency.js vs Handlebars

DOM templates vs. innerHTML templates

Why Transparency.js is so fast?

Transparency operates on DOM nodes instead of creating strings and then putting the resulting text through the (browser) HTML parser. Javascript engines driving DOM manipulation code have become faster and faster making this approach the fastest way of dealing with HTML templating.

There are variations between different web browsers and use cases but generally even in the worst scenario Transparency is at least as fast as competing solutions.

Also because Transparency templates do not need to be separately parsed or compiled Transparency does not increase the page load or Javascript code start-up time unlike the alternatives.

How small is it?

Transparency is written in CoffeeScript programming language which translates itself to more or less human-readable Javascript source code.

The translated .js file is 11 kBytes and minified version 4 kBytes as writing of this.

What license Transparency.js uses?


What to do if the data does not match the templates?

The whole point is to use Ubiquitous Language, so first, take a look on your data and templates and eliminate the differences. If that's not feasible, there's couple of options:

  • Use directives to provide the mapping
  • Preprocess the data to match the template before feeding it to Transparency.render().

Should I use Transparency on server-side?

Probably not. On the server-side the templates would go through string -> DOM -> fill -> string transformation. On the client side the templates go through string -> DOM -> fill transformation. In most cases there would not be benefits running Transparency on the server, unless you simply prefer the API cleanliness.

If you need something similar to Transparency you might want to check Plates (below).

Are there other semantic template engines/frameworks?

Besides Transparency, there are several other server- and client-side logicless templating libraries. Some operate in Javascript space, some are bound to other programming languages and platforms.