       @category = "collection_#{options.folder}"
       @entries = []
       @roots.config.locals[helperName] = decorateArray([])
+      @layoutFilename = "views/#{options.layout}.jade"
 
     frontmatter_regexp: /^---\n([^]*?)\n---\n([^]*)$/
     slug_date_regexp: /^([0-9]{4})-(\d\d?)-(\d\d?)-/
 
     fs: ->
+      extension = @
       extract: true
       ordered: true
       detect: (f) ->
-        if "views/#{options.layout}.jade" == f.relative
+        if f.relative == extension.layoutFilename
           true
         else
           path.dirname(f.relative) == folder

    after_category: (ctx, category) ->
      return unless category == @category

      adapter = @layoutFile.adapters[0]
      content = @layoutFile.originalContent
      opts = @configure_options(@layoutFile, adapter)

    )
  array

# The first time a layout is found it'll be marked as part of the category
# Keep a cache of layoutFiles to make sure it can be used by other collections as well
layoutFiles = {}

module.exports = (options) ->
  options ||= {}
  folder = options.folder || "posts"
