Cache information about document YAML header existence
This commit is contained in:
parent
a902fefed5
commit
5fdf637c6a
|
@ -15,6 +15,7 @@ module Jekyll
|
||||||
@site = relations[:site]
|
@site = relations[:site]
|
||||||
@path = path
|
@path = path
|
||||||
@collection = relations[:collection]
|
@collection = relations[:collection]
|
||||||
|
@has_yaml_header = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Fetch the Document's data.
|
# Fetch the Document's data.
|
||||||
|
@ -84,7 +85,8 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns true if the file starts with three dashes
|
# Returns true if the file starts with three dashes
|
||||||
def has_yaml_header?
|
def has_yaml_header?
|
||||||
!!(File.open(path, 'rb') { |f| f.read(5) } =~ /\A---\r?\n/)
|
@has_yaml_header unless @has_yaml_header.nil?
|
||||||
|
@has_yaml_header = !!(File.open(path, 'rb') { |f| f.read(5) } =~ /\A---\r?\n/)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determine whether the file should be rendered with Liquid.
|
# Determine whether the file should be rendered with Liquid.
|
||||||
|
|
Loading…
Reference in New Issue