mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
use before hooks to simplify server and move other code into features and extensions
This commit is contained in:
parent
7ffd5ccea9
commit
ca5921a72e
1 changed files with 18 additions and 15 deletions
|
@ -10,21 +10,24 @@ module Middleman::CoreExtensions::FrontMatter
|
|||
::Tilt::register RedClothTemplate, 'textile'
|
||||
::Tilt::register ERBTemplate, 'erb', 'rhtml'
|
||||
::Tilt::register ErubisTemplate, 'erb', 'rhtml', 'erubis'
|
||||
#
|
||||
# app.before do
|
||||
# full_file_path = "#{extensionless_path}.#{template_engine}"
|
||||
# system_path = File.join(settings.views, full_file_path)
|
||||
# data, content = self.class.parse_front_matter(File.read(system_path))
|
||||
#
|
||||
# %w(layout layout_engine).each do |opt|
|
||||
# if data.has_key?(opt)
|
||||
# options[opt.to_sym] = data.delete(opt)
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# # Forward remaining data to helpers
|
||||
# self.class.data_content("page", data)
|
||||
# end
|
||||
|
||||
app.before do
|
||||
result = resolve_template(request.path_info, :raise_exceptions => false)
|
||||
if 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))
|
||||
|
||||
%w(layout layout_engine).each do |opt|
|
||||
if data.has_key?(opt)
|
||||
options[opt.to_sym] = data.delete(opt)
|
||||
end
|
||||
end
|
||||
|
||||
# Forward remaining data to helpers
|
||||
app.data_content("page", data)
|
||||
end
|
||||
end
|
||||
end
|
||||
alias :included :registered
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue