lib/jekyll/page.rb in jekyll-3.0.5 vs lib/jekyll/page.rb in jekyll-3.1.0.pre.beta1
- old
+ new
@@ -14,10 +14,19 @@
name
path
url
]
+ # A set of extensions that are considered HTML or HTML-like so we
+ # should not alter them, this includes .xhtml through XHTM5.
+
+ HTML_EXTENSIONS = %W(
+ .html
+ .xhtml
+ .htm
+ )
+
# Initialize a new Page.
#
# site - The Site object.
# base - The String path to the source.
# dir - The String path between the source and the file.
@@ -106,16 +115,14 @@
# layouts - The Hash of {"name" => "layout"}.
# site_payload - The site payload Hash.
#
# Returns nothing.
def render(layouts, site_payload)
- payload = Utils.deep_merge_hashes({
- "page" => to_liquid,
- 'paginator' => pager.to_liquid
- }, site_payload)
+ site_payload.page = to_liquid
+ site_payload.paginator = pager.to_liquid
- do_layout(payload, layouts)
+ do_layout(site_payload, layouts)
end
# The path to the source file
#
# Returns the path to the source file
@@ -133,25 +140,22 @@
# dest - The String path to the destination dir.
#
# Returns the destination file path String.
def destination(dest)
path = site.in_dest_dir(dest, URL.unescape_path(url))
- if url.end_with? "/"
- path = File.join(path, "index.html")
- else
- path << output_ext unless path.end_with?(output_ext)
- end
+ path = File.join(path, "index") if url.end_with?("/")
+ path << output_ext unless path.end_with?(output_ext)
path
end
# Returns the object as a debug String.
def inspect
"#<Jekyll:Page @name=#{name.inspect}>"
end
# Returns the Boolean of whether this Page is HTML or not.
def html?
- output_ext == '.html'
+ HTML_EXTENSIONS.include?(output_ext)
end
# Returns the Boolean of whether this Page is an index file or not.
def index?
basename == 'index'