         return
       else
         filename = path.join(__dirname, '../views', view)+'.tpl'
+        console.log 'FILENAME = '+filename
         fs.readFile filename, 'utf-8', (err, content) ->
           return res.req.next(err) if err
           template = liquid.Template.parse(content)


module.exports = (app, mod) ->

  console.log process.env.MEMCACHED_LOCATIONS ? 'localhost:11211'
  try
    memcached = new Memcached(process.env.MEMCACHED_LOCATIONS ? 'localhost:11211')
    console.log 'memcached'
    console.log memcached
  catch err
    console.log err

  memcached.flush (err) ->
    console.log err
  #
  # * Render the template
  # * first look in cache

  #
  mod.render = (res, view, data = {}) ->

    console.log 'RENDER = '+view
    ###
     * Get the latest flash message from the middleware
    ###
    data.messages = res.req.flash()

    memcached.get view, (err, html) ->
      console.log 'TYPE = '+typeof(html)
      console.log err
      console.log html
      if 'string' is typeof html
