Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactored core template rendering facilities

  • Loading branch information...
commit a3296606b7b57ff0b2c8ea82500d2b612b5e594a 1 parent f78523b
@kadirpekel authored
Showing with 12 additions and 16 deletions.
  1. +12 −16 lib/coffeemate.coffee
View
28 lib/coffeemate.coffee
@@ -30,30 +30,26 @@ class CoffeemateContext
@resp.end()
# This method renders the template that read from given templateName
- # using eco template engine. It uses sync file read operation to obtain
- # template contents
+ # using eco template engine as default.
+ # It uses sync file read operation to obtain template contents
#
# @param {String} templateName
+ # @return {String}
# @api public
- render: (templateName) ->
+ include: (templateName) ->
templatePath = path.join process.cwd(),
@container.options.renderDir,
"#{templateName}#{@container.options.renderExt}"
template = fs.readFileSync templatePath
- @resp.end @container.options.renderFunc "#{template}", @
-
- # This method renders and includes the partial template that read and rendered
- # from given partial template name.
+ @container.options.renderFunc "#{template}", @
+
+ # This method renders the template that read from given templateName
+ # and writes the output to the client socket stream
#
- # @param {String} partialName
- # @return {String}
- # @api public
- include: (partialName) ->
- partialPath = path.join process.cwd(),
- @container.options.renderDir,
- "#{partialName}#{@container.options.renderExt}"
- partial = fs.readFileSync partialPath
- @container.options.renderFunc "#{partial}", @
+ # @param {String} templateName
+ # @api public
+ render: (templateName) ->
+ @resp.end @include templateName
# Coffeemate core object
# Kindly extends connect.HTTPServer and pours some sugar on it.
Please sign in to comment.
Something went wrong with that request. Please try again.