Browse Source

explained why templish exists

mort 7 years ago
1 changed files with 19 additions and 0 deletions
  1. 19

+ 19
- 0 View File

@@ -2,6 +2,25 @@

A templating language for JavaScript, using JavaScript.

## Why?

There are other templating languages out there. However, most of them don't really let you have a lot of logic in your templates. While those languages have their uses, it's often useful to have some logic in your templates.

Templish isn't meant to be used like traditional bad PHP code, hvere you have view logic and business logic in the same file with little to no distinction; most people will want to have each template stored in its own file, and have all business logic handled outside of templates, like you would with any other node.js web server. An example of a case where you would want logic in your templates is a list template where you want to alternate the color of the entries. With templish, this could be achieved like this:

``` JavaScript
var str = "";
rows.forEach(function(row, i) {
var c = "type"+(i % 2);
str += "<li class='"+c+"'>"+row+"</li>";
return str;

With a templating language which does not allow arbitrary logic, things like that may have to be done in a more complicated way outside of templates.

## Installation

Install with NPM: