Skip to content
Browse files

In `ck.render`, option `cache` is now `false` by default.

  • Loading branch information...
1 parent 99ff120 commit af9cfe58f1f07770a1400ae1167a9541eb68f4e1 @mauricemach committed Jul 26, 2011
Showing with 19 additions and 11 deletions.
  1. +2 −0 CHANGELOG.md
  2. +14 −8 benchmark.coffee
  3. +1 −1 docs/coffeekup.html
  4. +1 −1 docs/reference.md
  5. +1 −1 src/coffeekup.coffee
View
2 CHANGELOG.md
@@ -31,6 +31,8 @@
- Added IE conditional comments: `ie 'lt IE8', -> 'IE 7 or less specific stuff'` (thanks @aeosynth).
- Using '.call(this);' instead of '();' in js generated by the 'coffeescript' tag.
+
+ - In `coffeekup.render`, option `cache` is now `false` by default.
**v0.2.3** (2011-05-06):
View
22 benchmark.coffee
@@ -187,15 +187,21 @@ benchmark = (title, code) ->
@run = ->
benchmark 'CoffeeKup (precompiled)', -> coffeekup_compiled_template data
- benchmark 'CoffeeKup (code)', -> coffeekup.render coffeekup_template, data
- benchmark 'CoffeeKup (code, cache off)', -> coffeekup.render coffeekup_template, data, cache: off
- benchmark 'CoffeeKup (string)', -> coffeekup.render coffeekup_string_template, data, cache: on
- benchmark 'CoffeeKup (string, cache off)', -> coffeekup.render coffeekup_string_template, data, cache: off
benchmark 'Jade (precompiled)', -> jade_compiled_template data
- benchmark 'Jade (cache off)', -> jade.render jade_template, locals: data
- benchmark 'Jade (cache on)', -> jade.render jade_template, locals: data, cache: on, filename: 'test'
+ benchmark 'haml-js (precompiled)', -> haml_template_compiled data
benchmark 'Eco', -> eco.render eco_template, data
- benchmark 'ejs (cache off)', -> ejs.render ejs_template, locals: data
+
+ console.log '\n'
+
+ benchmark 'CoffeeKup (function, cache on)', -> coffeekup.render coffeekup_template, data, cache: on
+ benchmark 'CoffeeKup (string, cache on)', -> coffeekup.render coffeekup_string_template, data, cache: on
+ benchmark 'Jade (cache on)', -> jade.render jade_template, locals: data, cache: on, filename: 'test'
benchmark 'ejs (cache on)', -> ejs.render ejs_template, locals: data, cache: on, filename: 'test'
+
+ console.log '\n'
+
+ benchmark 'CoffeeKup (function, cache off)', -> coffeekup.render coffeekup_template, data
+ benchmark 'CoffeeKup (string, cache off)', -> coffeekup.render coffeekup_string_template, data, cache: off
+ benchmark 'Jade (cache off)', -> jade.render jade_template, locals: data
benchmark 'haml-js', -> haml.render haml_template, locals: data
- benchmark 'haml-js (precompiled)', -> haml_template_compiled data
+ benchmark 'ejs (cache off)', -> ejs.render ejs_template, locals: data
View
2 docs/coffeekup.html
@@ -236,7 +236,7 @@
<code>locals</code> and <code>hardcode</code>), and the template (which understands the options
<code>format</code> and <code>autoescape</code>).</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">coffeekup.render = </span><span class="nf">(template, data = {}, options = {}) -&gt;</span>
<span class="nx">data</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span> <span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">options</span>
- <span class="nx">data</span><span class="p">.</span><span class="nx">cache</span> <span class="o">?=</span> <span class="kc">on</span>
+ <span class="nx">data</span><span class="p">.</span><span class="nx">cache</span> <span class="o">?=</span> <span class="kc">off</span>
<span class="k">if</span> <span class="nx">data</span><span class="p">.</span><span class="nx">cache</span> <span class="o">and</span> <span class="nx">cache</span><span class="p">[</span><span class="nx">template</span><span class="p">]</span><span class="o">?</span> <span class="k">then</span> <span class="nv">tpl = </span><span class="nx">cache</span><span class="p">[</span><span class="nx">template</span><span class="p">]</span>
<span class="k">else</span> <span class="k">if</span> <span class="nx">data</span><span class="p">.</span><span class="nx">cache</span> <span class="k">then</span> <span class="nv">tpl = </span><span class="nx">cache</span><span class="p">[</span><span class="nx">template</span><span class="p">]</span> <span class="o">=</span> <span class="nx">coffeekup</span><span class="p">.</span><span class="nx">compile</span><span class="p">(</span><span class="nx">template</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span>
View
2 docs/reference.md
@@ -42,7 +42,7 @@ Compiles the template provided, runs it, and returns the resulting HTML string.
Options:
-- `cache`: `true` by default. Whether to reuse compiled templates, or re-compile them every time.
+- `cache`: `false` by default. Whether to reuse compiled templates, or re-compile them every time.
### version
View
2 src/coffeekup.coffee
@@ -302,7 +302,7 @@ cache = {}
#
coffeekup.render = (template, data = {}, options = {}) ->
data[k] = v for k, v of options
- data.cache ?= on
+ data.cache ?= off
if data.cache and cache[template]? then tpl = cache[template]
else if data.cache then tpl = cache[template] = coffeekup.compile(template, data)

0 comments on commit af9cfe5

Please sign in to comment.
Something went wrong with that request. Please try again.