moot/riotjs — pull request #7 by eviltrout (2013-11-01 17:29:23+00:00)
Title: Performance: Giant speed up of Riot templating language

I was fascinated by your benchmarks on your [blog post about riot.js](https://moot.it/blog/technology/riotjs-the-1kb-mvp-framework.html).

In particular I really enjoyed this chart, which compared riot.js to handlebars, especially how 7ms in two places has two totally different lengths!

![handlebars](https://f.cloud.github.com/assets/17538/1455438/8215266e-431a-11e3-9fb4-fd3fc0e9f48d.png)

Anyway after being inspired by that chart I thought surely there is a way to make riot.js' templating language *even faster* than handlebars.

The current riot.js templating language is a simple regexp:

```javascript
$.trim(template).replace(/\n/g, "").replace(/\{([^\}]+)\}/g, "'+_.$1+'") + "'")
```

So the "secret" to having the world's fastest templating language for the world's "most powerful client side framework"(tm) is to just throw away useless features like data binding, conditional statements and loops. Who needs those right?

I think you can even take it further! Why even do variable substitutions? Why even bother returning strings?

This patch is 100,000x faster than riot's current implementation. You're welcome!