Add Utils.has_yaml_header? so we can check the front matter existence in one place
This commit is contained in:
parent
bcc539999b
commit
f16a5cbae1
|
@ -1,6 +1,6 @@
|
|||
module Jekyll
|
||||
module Utils
|
||||
class << self
|
||||
extend self
|
||||
|
||||
# Merges a master hash with another hash, recursively.
|
||||
#
|
||||
|
@ -95,6 +95,12 @@ module Jekyll
|
|||
raise Errors::FatalException.new("Invalid date '#{input}': " + msg)
|
||||
end
|
||||
|
||||
# Determines whether a given file has
|
||||
#
|
||||
# Returns true if the YAML front matter is present.
|
||||
def has_yaml_header?(file)
|
||||
!!(File.open(file, 'rb') { |f| f.read(5) } =~ /\A---\r?\n/)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue