Skip to content

Commit

Permalink
v2.4.1. Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Jun 25, 2013
1 parent 9f30ff9 commit 6a244ef
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## History

- v2.3.2 June 26, 2013
- v2.4.1 June 26, 2013
- Fixed regression with the template helpers and jade v0.31

- v2.4.0 June 26, 2013
- Dependency updates
- Repackaged

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docpad-plugin-jade",
"version": "2.3.2",
"version": "2.4.1",
"description": "Adds support for the Jade templating engine to DocPad.",
"homepage": "http://docpad.org/plugin/jade",
"keywords": [
Expand Down
15 changes: 11 additions & 4 deletions src/jade.plugin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ module.exports = (BasePlugin) ->
# No special opts
if opts.args
args = str.split(/\s*\n\s*/)
return value.apply(templateData,args)
return value.apply(templateData, args)
else
args = [str,opts]
return value.apply(templateData,args)
return value.apply(templateData ,args)

# Add template helpers as jade filters
for own key,value of templateData
if Object::toString.call(value) is '[object Function]'
addTemplateDataAsFilter(key,value)
addTemplateDataAsFilter(key, value)

# Chain
@
Expand All @@ -65,7 +65,14 @@ module.exports = (BasePlugin) ->

# Render
try
opts.content = @jade.compile(opts.content,jadeOptions)(templateData)
# Ensure template data is bounded
# required for jade 0.31+, earlier versions didn't require it
for own key,value of templateData
if Object::toString.call(value) is '[object Function]'
templateData[key] = value.bind(templateData)

# Compile
opts.content = @jade.compile(opts.content, jadeOptions)(templateData)
catch err
return next(err)

Expand Down
1 change: 1 addition & 0 deletions test/out-expected/jade.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

<h1>Jade Example</h1><p>ECO to <em>markdown</em> to html. my url is /jade.html</p>
<meta http-equiv="X-Powered-By" content="DocPad vXXX"/>/jade.html
4 changes: 4 additions & 0 deletions test/src/documents/jade.html.jade
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ h1 Jade Example

:t(render="html.md.eco")
<%-'eco'.toUpperCase()%> to *markdown* to html. my url is <%-@document.url%>

!= getBlock('meta').toHTML().replace(/v[0-9\.]+/, 'vXXX')

!= getCollection('documents').pluck('url').join('<br/>')

0 comments on commit 6a244ef

Please sign in to comment.