 	# Render this file
 	# next(err,finalExtension)
 	render: (templateData,next) ->
+		# Prepare
+		docpad = @docpad
+		logger = @logger
+		file = @
+
 		# Log
-		@logger.log 'debug', "Rendering the file #{@relativePath}"
-
-		# Prepare
-		@contentRendered = @content
-		@content = @contentSrc
-
-		# Async
-		tasks = new util.Group (err) =>
+		logger.log 'debug', "Rendering the file #{@relativePath}"
+
+		# Prepare reset
+		reset = ->
+			file.rendered = false
+			file.content = file.body
+			file.contentRendered = file.body
+			file.contentRenderedWithoutLayouts = file.body
+			file.contentRenderings = [{
+				content: file.content
+				extension: file.extension
+			}]
+			file.contentRenderingsByLayout = {
+				none: [
+					content: file.content
+					extension: file.extension
+				]
+			}
+
+		# Prepare complete
+		finish = (err) ->
+			# Reset the content to it's original value
+			file.content = file.body
+
+			# Error
 			return next?(err)  if err
-
-			# Reset content
-			@content = @contentSrc
-
-			# Wrap in layout
-			if @layout
-				@getLayout (err,layout) =>
+			
+			# Log
+			logger.log 'debug', "Rendering completed for #{file.relativePath}"
+			
+			# Success
+			file.rendered = true
+			return next?()
+		
+		# Prepare render layouts
+		# next(err)
+		renderLayouts = (next) ->
+			# Store the content without any layout rendering
+			file.contentRenderedWithoutLayouts = file.content
+
+			# Skip ahead if we don't have a layout
+			return next?()  unless file.layout
+			
+			# Grab the layout
+			file.getLayout (err,layout) ->
+				# Error
+				return next?(err)  if err
+
+				# Assign the rendered file content to the templateData.content
+				templateData.content = file.contentRendered
+
+				# Render the layout with the templateData
+				layout.render templateData, (err) ->
+					# Error
 					return next?(err)  if err
-					templateData.content = @contentRendered
-					layout.render templateData, (err) =>
-						@contentRendered = layout.contentRendered
-						@logger.log 'debug', "Rendering completed for #{@relativePath}"
-						next?(err)
-			else
-				@logger.log 'debug', "Rendering completed for #{@relativePath}"
-				next?(err)
-		
-		# Check tasks
-		if @extensions.length <= 1
-			# No rendering necessary
-			tasks.total = 1
-			tasks.complete()
-			return
-		
-		# Clone extensions
-		extensions = []
-		for extension in @extensions
-			extensions.unshift extension
-
-		# Cycle through all the extension groups
-		previousExtension = null
-		for extension in extensions
-			# Has a previous extension
-			if previousExtension
-				# Event data
-				eventData = 
-					inExtension: previousExtension
-					outExtension: extension
-					templateData: templateData
-					file: @
-				
-				# Create a task to run
-				tasks.push ((eventData) => =>
-					# Render through plugins
-					@docpad.triggerPluginEvent 'render', eventData, (err) =>
-						# Error?
-						if err
-							@logger.log 'warn', 'Something went wrong while rendering:', @relativePath
-							return tasks.exit(err)
-
-						# Update rendered content
-						@contentRendered = @content
-
-						# Complete
-						tasks.complete(err)
-				
-				)(eventData)
-
-			# Cycle
-			previousExtension = extension
-		
-		# Run tasks synchronously
-		tasks.sync()
+
+					# Apply the rendering
+					file.contentRendered = layout.contentRendered
+					for own key,value of layout.contentRenderingsByLayout
+						if key is 'none'
+							file.contentRenderingsByLayout[layout.relativeBase] = value
+						else
+							file.contentRenderingsByLayout[key] = value
+
+					# Success
+					return next?()
+		
+		# Prepare render extensions
+		# next(err)
+		renderExtensions = (next) =>
+			# If we only have one extension, then skip ahead to rendering layouts
+			return next?()  if file.extensions.length <= 1
+
+			# Prepare the tasks
+			tasks = new util.Group next
+
+			# Clone extensions
+			extensions = []
+			for extension in file.extensions
+				extensions.unshift extension
+
+			# Cycle through all the extension groups
+			previousExtension = null
+			for extension in extensions
+				# Has a previous extension
+				if previousExtension
+					# Event data
+					eventData = 
+						inExtension: previousExtension
+						outExtension: extension
+						templateData: templateData
+						file: file
+					
+					# Create a task to run
+					tasks.push ((file,eventData) -> ->
+						# Render through plugins
+						docpad.triggerPluginEvent 'render', eventData, (err) ->
+							# Error?
+							if err
+								logger.log 'warn', 'Something went wrong while rendering:', file.relativePath
+								return tasks.exit(err)
+
+							# Update rendered content
+							file.contentRendered = file.content
+							file.contentRenderings.push(
+								content: file.contentRendered
+								extension: eventData.outExtension
+							)
+							file.contentRenderingsByLayout.none.push(
+								content: file.contentRendered
+								extension: eventData.outExtension
+							)
+
+							# Complete
+							return tasks.complete(err)
+					
+					)(file,eventData)
+
+				# Cycle
+				previousExtension = extension
+			
+			# Run tasks synchronously
+			return tasks.sync()
+
+		# Reset everything
+		reset()
+
+		# Render the extensions, then the layouts, then finish
+		renderExtensions (err) ->
+			return finish(err)  if err
+			renderLayouts (err) ->
+				return finish(err)
 
 		# Chain
 		@

	# Parses some data, and loads the meta data and content from it
	# next(err)
	parse: (fileData,next) ->
		# Handle data
		fileData = fileData.replace(/\r\n?/gm,'\n').replace(/\t/g,'    ')
		@fileBody = fileData
		@fileHead = null
		@fileMeta = {}
	
		# Meta Data
		match = /^\s*([\-\#][\-\#][\-\#]+) ?(\w*)\s*/.exec(fileData)
		if match
			# Positions
			seperator = match[1]
			a = match[0].length
			b = fileData.indexOf("\n#{seperator}",a)+1
			c = b+3

			# Parts
			@fileHead = fileData.substring(a,b)
			@fileBody = fileData.substring(c)
			@fileHeadParser = match[2] or 'yaml'

			# Language
			try
				switch @fileHeadParser
					when 'coffee', 'cson'
						coffee = require('coffee-script')  unless coffee
						@fileMeta = coffee.eval @fileHead, filename: @fullPath
					
					when 'yaml'
						yaml = require('yaml')  unless yaml
						@fileMeta = yaml.eval(@fileHead)
					
					else
						@fileMeta = {}
						err = new Error("Unknown meta parser [#{@fileHeadParser}]")
						return next?(err)
			catch err
				return next?(err)
		
		# Update Meta
		@fileMeta or= {}
		@content = @fileBody
		@contentSrc = @fileBody
		@contentRaw = fileData
		@contentRendered = @fileBody
		@title = @title or @basename or @filename
	
		# Correct meta data
		@fileMeta.date = new Date(@fileMeta.date)  if @fileMeta.date? and @fileMeta.date
		
		# Handle urls
		@addUrl @fileMeta.urls  if @fileMeta.urls?
		@addUrl @fileMeta.url  if @fileMeta.url?

		# Apply user meta
		for own key, value of @fileMeta
			@[key] = value
		
		# Next

	# The unique document identifier
	id: null
	
	# The file's name without the extension
	basename: null

	# The file's last extension
	# "hello.md.eco" -> "eco"
	extension: null

	# The file's extensions as an array, in reverse order
	# "hello.md.eco" -> ["eco","md"]
	extensions: []

	# The final extension used for our rendered file
	# Takes into accounts layouts
	# "layout.html", "post.md.eco" -> "html"
	extensionRendered: null

	# The file's name with the extension
	filename: null

	# The file's name with the rendered extension
	filenameRendered: null

	# The full path of our file, only necessary if called by @load
	fullPath: null

	# The final rendered path of our file
	outPath: null

	# The relative path of our source file (with extensions)
