Allow non-templates to have frontmatter. Closes #698
This commit is contained in:
parent
a537b434e3
commit
6253c91610
|
@ -11,6 +11,16 @@ Feature: YAML Front Matter
|
|||
Then I should see "<?php"
|
||||
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
|
||||
Given the Server is running at "frontmatter-app"
|
||||
When I go to "/front-matter-line-2.html"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
layout: false
|
||||
title: This is the title
|
||||
---
|
||||
|
||||
<h1><%= data.page.title %></h1>
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
layout: false
|
||||
title: This is the title
|
||||
---
|
||||
|
||||
<?php echo "sup"; ?>
|
|
@ -247,9 +247,6 @@ module Middleman
|
|||
|
||||
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
|
||||
content_type(res, resource.mime_type)
|
||||
|
||||
|
|
|
@ -111,7 +111,9 @@ module Middleman
|
|||
# Render this resource
|
||||
# @return [String]
|
||||
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))
|
||||
|
||||
|
|
Loading…
Reference in a new issue