frontmatter test
This commit is contained in:
parent
edb60cd83a
commit
ef51434146
5 changed files with 62 additions and 61 deletions
|
@ -14,19 +14,20 @@ module Middleman::CoreExtensions::FrontMatter
|
|||
|
||||
app.before do
|
||||
result = resolve_template(request.path_info, :raise_exceptions => false)
|
||||
if result
|
||||
|
||||
if result && Tilt.mappings.has_key?(result[1].to_s)
|
||||
extensionless_path, template_engine = result
|
||||
full_file_path = "#{extensionless_path}.#{template_engine}"
|
||||
system_path = File.join(settings.views, full_file_path)
|
||||
data, content = app.parse_front_matter(File.read(system_path))
|
||||
|
||||
|
||||
request['custom_options'] = {}
|
||||
%w(layout layout_engine).each do |opt|
|
||||
if data.has_key?(opt)
|
||||
request['custom_options'][opt.to_sym] = data.delete(opt)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Forward remaining data to helpers
|
||||
app.data_content("page", data)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue