remove confusing and broken data.page variable
This commit is contained in:
parent
98e3c8aa79
commit
504a1c2eba
|
@ -1,6 +1,7 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
|
* Asciidoc information now available with the `asciidoc` local, which is a normal hash.
|
||||||
* Remove `page` template local. Use `current_resource` instead.
|
* Remove `page` template local. Use `current_resource` instead.
|
||||||
* Dropped support for `page` & `proxy` blocks.
|
* Dropped support for `page` & `proxy` blocks.
|
||||||
* Dropped support for instance variables inside templates.
|
* Dropped support for instance variables inside templates.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><%= data.page.title || 'Fallback' %></title>
|
<title><%= current_resource.data.title || asciidoc[:title] || 'Fallback' %></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
|
|
@ -41,11 +41,19 @@ module Middleman::CoreExtensions
|
||||||
fmdata = data(path).first
|
fmdata = data(path).first
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
[:layout, :layout_engine].each do |opt|
|
[:layout, :layout_engine].each do |opt|
|
||||||
data[opt] = fmdata[opt] unless fmdata[opt].nil?
|
data[opt] = fmdata[opt] unless fmdata[opt].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
{ :options => data, :page => ::Middleman::Util.recursively_enhance(fmdata).freeze }
|
if fmdata[:renderer_options]
|
||||||
|
data[:renderer_options] = {}
|
||||||
|
fmdata[:renderer_options].each do |k, v|
|
||||||
|
data[:renderer_options][k.to_sym] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
{ :options => data }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ module Middleman
|
||||||
# TODO grab all the author information
|
# TODO grab all the author information
|
||||||
page[:author] = (doc.attr 'author') unless (doc.attr 'author').nil?
|
page[:author] = (doc.attr 'author') unless (doc.attr 'author').nil?
|
||||||
|
|
||||||
{:options => opts, :page => ::Middleman::Util.recursively_enhance(page)}
|
{ :options => opts, :locals => { :asciidoc => page } }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Middleman
|
||||||
@source_file = source_file
|
@source_file = source_file
|
||||||
@destination_path = @path
|
@destination_path = @path
|
||||||
|
|
||||||
@local_metadata = { :options => {}, :locals => {}, :page => {}}
|
@local_metadata = { :options => {}, :locals => {} }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether this resource has a template file
|
# Whether this resource has a template file
|
||||||
|
@ -104,22 +104,7 @@ module Middleman
|
||||||
instrument 'render.resource', :path => relative_source do
|
instrument 'render.resource', :path => relative_source do
|
||||||
md = metadata.dup
|
md = metadata.dup
|
||||||
opts = md[:options].deep_merge(opts)
|
opts = md[:options].deep_merge(opts)
|
||||||
|
|
||||||
# Pass "renderer_options" hash from frontmatter along to renderer
|
|
||||||
if md[:page]['renderer_options']
|
|
||||||
opts[:renderer_options] = {}
|
|
||||||
md[:page]['renderer_options'].each do |k, v|
|
|
||||||
opts[:renderer_options][k.to_sym] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
locs = md[:locals].deep_merge(locs)
|
locs = md[:locals].deep_merge(locs)
|
||||||
|
|
||||||
# Forward remaining data to helpers
|
|
||||||
if md.has_key?(:page)
|
|
||||||
app.data.store('page', md[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
locs[:current_path] ||= self.destination_path
|
locs[:current_path] ||= self.destination_path
|
||||||
|
|
||||||
# Certain output file types don't use layouts
|
# Certain output file types don't use layouts
|
||||||
|
|
|
@ -137,7 +137,7 @@ module Middleman
|
||||||
# @param [String] source_file
|
# @param [String] source_file
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def metadata_for_file(source_file)
|
def metadata_for_file(source_file)
|
||||||
blank_metadata = { :options => {}, :locals => {}, :page => {} }
|
blank_metadata = { :options => {}, :locals => {} }
|
||||||
|
|
||||||
provides_metadata.inject(blank_metadata) do |result, (callback, matcher)|
|
provides_metadata.inject(blank_metadata) do |result, (callback, matcher)|
|
||||||
next result if matcher && !source_file.match(matcher)
|
next result if matcher && !source_file.match(matcher)
|
||||||
|
@ -165,7 +165,7 @@ module Middleman
|
||||||
def metadata_for_path(request_path)
|
def metadata_for_path(request_path)
|
||||||
return @_cached_metadata[request_path] if @_cached_metadata[request_path]
|
return @_cached_metadata[request_path] if @_cached_metadata[request_path]
|
||||||
|
|
||||||
blank_metadata = { :options => {}, :locals => {}, :page => {} }
|
blank_metadata = { :options => {}, :locals => {} }
|
||||||
|
|
||||||
@_cached_metadata[request_path] = provides_metadata_for_path.inject(blank_metadata) do |result, (callback, matcher)|
|
@_cached_metadata[request_path] = provides_metadata_for_path.inject(blank_metadata) do |result, (callback, matcher)|
|
||||||
case matcher
|
case matcher
|
||||||
|
|
Loading…
Reference in a new issue