Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Additions to pull #74.

  • Loading branch information...
commit 177bcc387305cb295fd35a326b0cc378e6d917d2 1 parent 5d0d79f
@mauricemach authored
View
1  CHANGELOG.md
@@ -1,6 +1,7 @@
**v0.3.0edge** (unreleased):
- Fixed #71: indexOf not supported in IE7 (thanks @jaekwon).
+ - Added better error reporting to express adapter. [benekastah]
**v0.3.0** (2011-09-04):
View
23 docs/coffeekup.html
@@ -14,7 +14,7 @@
<span class="nv">coffeekup = </span><span class="nx">exports</span>
<span class="nv">coffee = </span><span class="nx">require</span> <span class="s1">&#39;coffee-script&#39;</span>
-<span class="nv">coffeekup.version = </span><span class="s1">&#39;unreleased&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Values available to the <code>doctype</code> function inside a template.
+<span class="nv">coffeekup.version = </span><span class="s1">&#39;0.3.0edge&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Values available to the <code>doctype</code> function inside a template.
Ex.: <code>doctype 'strict'</code></p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">coffeekup.doctypes =</span>
<span class="s1">&#39;default&#39;</span><span class="o">:</span> <span class="s1">&#39;&lt;!DOCTYPE html&gt;&#39;</span>
<span class="s1">&#39;5&#39;</span><span class="o">:</span> <span class="s1">&#39;&lt;!DOCTYPE html&gt;&#39;</span>
@@ -253,11 +253,24 @@
<span class="nx">unless</span> <span class="nb">window</span><span class="o">?</span>
<span class="nv">coffeekup.adapters =</span></pre></div> </td> </tr> <tr id="section-31"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-31">&#182;</a> </div> <p>Legacy adapters for when CoffeeKup expected data in the <code>context</code> attribute.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">simple: </span><span class="nx">coffeekup</span><span class="p">.</span><span class="nx">render</span>
<span class="nv">meryl: </span><span class="nx">coffeekup</span><span class="p">.</span><span class="nx">render</span>
- </pre></div> </td> </tr> <tr id="section-32"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-32">&#182;</a> </div> <p>Allows <code>partial 'foo'</code> instead of <code>text @partial 'foo'</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">express:</span>
- <span class="nv">compile: </span><span class="nf">(template, data) -&gt;</span>
- <span class="nx">data</span><span class="p">.</span><span class="nx">hardcode</span> <span class="o">?=</span> <span class="p">{}</span>
+
+ <span class="nv">express:</span>
+ <span class="nv">TemplateError: </span><span class="k">class</span> <span class="k">extends</span> <span class="nb">Error</span>
+ <span class="nv">constructor: </span><span class="nf">(@message) -&gt;</span>
+ <span class="nb">Error</span><span class="p">.</span><span class="nx">call</span> <span class="k">this</span><span class="p">,</span> <span class="nx">@message</span>
+ <span class="nb">Error</span><span class="p">.</span><span class="nx">captureStackTrace</span> <span class="k">this</span><span class="p">,</span> <span class="nx">arguments</span><span class="p">.</span><span class="nx">callee</span>
+ <span class="nv">name: </span><span class="s1">&#39;TemplateError&#39;</span>
+
+ <span class="nv">compile: </span><span class="nf">(template, data) -&gt;</span> </pre></div> </td> </tr> <tr id="section-32"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-32">&#182;</a> </div> <p>Allows <code>partial 'foo'</code> instead of <code>text @partial 'foo'</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">data</span><span class="p">.</span><span class="nx">hardcode</span> <span class="o">?=</span> <span class="p">{}</span>
<span class="nv">data.hardcode.partial = </span><span class="o">-&gt;</span>
<span class="nx">text</span> <span class="nx">@partial</span><span class="p">.</span><span class="nx">apply</span> <span class="err">@</span><span class="p">,</span> <span class="nx">arguments</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>
+
+ <span class="nv">TemplateError = </span><span class="nx">@TemplateError</span>
+ <span class="k">try</span> <span class="nv">tpl = </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>
+ <span class="k">catch</span> <span class="nx">e</span> <span class="k">then</span> <span class="k">throw</span> <span class="k">new</span> <span class="nx">TemplateError</span> <span class="s2">&quot;Error compiling #{data.filename}: #{e.message}&quot;</span>
+
+ <span class="k">return</span> <span class="o">-&gt;</span>
+ <span class="k">try</span> <span class="nx">tpl</span> <span class="nx">arguments</span><span class="p">...</span>
+ <span class="k">catch</span> <span class="nx">e</span> <span class="k">then</span> <span class="k">throw</span> <span class="k">new</span> <span class="nx">TemplateError</span> <span class="s2">&quot;Error rendering #{data.filename}: #{e.message}&quot;</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
1  package.json
@@ -17,6 +17,7 @@
"Vladimir Dronnikov <dronnikov@gmail.com>",
"James Campos <james.r.campos@gmail.com>",
"Martin Westergaard Lassen <martin@mwl.dk>",
+ "Paul Harper <benekastah@gmail.com>",
"Esa-Matti Suuronen <esa-matti@suuronen.org>",
"Jason King <jasonk@amcoonline.net>",
"Brandon Bloom <brandon@brandonbloom.name>",
View
9 src/coffeekup.coffee
@@ -334,14 +334,15 @@ unless window?
simple: coffeekup.render
meryl: coffeekup.render
- # Allows `partial 'foo'` instead of `text @partial 'foo'`.
express:
TemplateError: class extends Error
constructor: (@message) ->
Error.call this, @message
Error.captureStackTrace this, arguments.callee
- name: "TemplateError"
+ name: 'TemplateError'
+
compile: (template, data) ->
+ # Allows `partial 'foo'` instead of `text @partial 'foo'`.
data.hardcode ?= {}
data.hardcode.partial = ->
text @partial.apply @, arguments
@@ -349,7 +350,7 @@ unless window?
TemplateError = @TemplateError
try tpl = coffeekup.compile(template, data)
catch e then throw new TemplateError "Error compiling #{data.filename}: #{e.message}"
-
+
return ->
try tpl arguments...
- catch e then throw new TemplateError "Error rendering #{data.filename}: #{e.message}"
+ catch e then throw new TemplateError "Error rendering #{data.filename}: #{e.message}"
Please sign in to comment.
Something went wrong with that request. Please try again.