Allow non-templates to have frontmatter. Closes #698

This commit is contained in:
Thomas Reynolds 2012-12-30 20:29:39 -08:00
parent a537b434e3
commit 6253c91610
5 changed files with 25 additions and 4 deletions

View file

@ -11,6 +11,16 @@ Feature: YAML Front Matter
Then I should see "<?php" Then I should see "<?php"
Then I should not see "---" Then I should not see "---"
Scenario: Rendering raw (template-less) (yaml)
Given the Server is running at "frontmatter-app"
When I go to "/raw-front-matter.html"
Then I should see "<h1><%= data.page.title %></h1>"
Then I should not see "---"
When I go to "/raw-front-matter.php"
Then I should see '<?php echo "sup"; ?>'
Then I should see "<?php"
Then I should not see "---"
Scenario: YAML not on first line, no encoding Scenario: YAML not on first line, no encoding
Given the Server is running at "frontmatter-app" Given the Server is running at "frontmatter-app"
When I go to "/front-matter-line-2.html" When I go to "/front-matter-line-2.html"

View file

@ -0,0 +1,6 @@
---
layout: false
title: This is the title
---
<h1><%= data.page.title %></h1>

View file

@ -0,0 +1,6 @@
---
layout: false
title: This is the title
---
<?php echo "sup"; ?>

View file

@ -247,9 +247,6 @@ module Middleman
current_path = resource.destination_path current_path = resource.destination_path
# If this path is a static file, send it immediately
return send_file(resource.source_file, env, res) unless resource.template?
# Set a HTTP content type based on the request's extensions # Set a HTTP content type based on the request's extensions
content_type(res, resource.mime_type) content_type(res, resource.mime_type)

View file

@ -111,7 +111,9 @@ module Middleman
# Render this resource # Render this resource
# @return [String] # @return [String]
def render(opts={}, locs={}, &block) def render(opts={}, locs={}, &block)
return File.open(source_file).read unless template? if !template?
return app.template_data_for_file(source_file)
end
relative_source = Pathname(source_file).relative_path_from(Pathname(app.root)) relative_source = Pathname(source_file).relative_path_from(Pathname(app.root))