Permalink
Browse files

change readme.md for it options

  • Loading branch information...
1 parent 64cb7f6 commit 7c0624b09821c1a3448025418a0ac5d46e3190f0 @fengmk2 fengmk2 committed Apr 30, 2011
Showing with 22 additions and 2 deletions.
  1. +19 −0 Readme.md
  2. +2 −1 benchmark.js
  3. +1 −1 lib/ejs.js
View
@@ -22,6 +22,12 @@ Embedded JavaScript templates.
<% if (user) { %>
<h2><%= user.name %></h2>
<% } %>
+
+ // High speed mode: options.it = true;
+
+ <% if (it.user) { %>
+ <h2><%= it.user.name %></h2>
+ <% } %>
## Usage
@@ -40,6 +46,7 @@ Embedded JavaScript templates.
- `debug` Output generated function body
- `open` Open tag, defaulting to "<%"
- `close` Closing tag, defaulting to "%>"
+ - `it` High performance render option, if it is true, will be _100%_ speed up; false by default
## Custom Tags
@@ -111,6 +118,18 @@ Currently these filters are available:
- reverse
- get:'prop'
+## High Speed mode: ejs.it = true;
+
+If you set option `it` to true, there will be 100% render speed up:
+
+ var ejs = require('ejs');
+ // global settings
+ ejs.it = true;
+
+You must use `it.var_name` to access your template locals variables:
+
+ <h1><%= it.title %></h1>
+
## License
(The MIT License)
View
@@ -13,13 +13,14 @@ while (times--) {
console.log('took ' + (new Date - start) + 'ms');
+ejs.it = true;
var str_it = '<% if (it.foo) { %><p><%= it.foo %></p><% } %>';
times = 50000;
console.log('options.it true: rendering ' + times + ' times');
var start = new Date;
while (times--) {
- ejs.render(str_it, { it: true, cache: true, filename: 'test_it_true', locals: { foo: 'bar' }});
+ ejs.render(str_it, { cache: true, filename: 'test_it_true', locals: { foo: 'bar' }});
}
console.log('took ' + (new Date - start) + 'ms');
View
@@ -109,7 +109,7 @@ var parse = exports.parse = function(str, options){
var options = options || {}
, open = options.open || exports.open || '<%'
, close = options.close || exports.close || '%>'
- , it = options.it || false; // use it you will get 100% performance speed up
+ , it = options.it || exports.it || false; // use it you will get 100% performance speed up
var buf = [
"var buf = [];"

0 comments on commit 7c0624b

Please sign in to comment.