-
Notifications
You must be signed in to change notification settings - Fork 112
Frequently Asked Questions
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.
- 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
Try
- #transparency.js IRC channel on irc.freenode.net - Web IRC access
- Google discussion group
DOM templates vs. innerHTML templates
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.
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.
MIT
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()
.
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).
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.