Add Utils.has_yaml_header? so we can check the front matter existence in one place

This commit is contained in:
Parker Moore 2014-08-12 15:58:02 -04:00
parent bcc539999b
commit f16a5cbae1
1 changed files with 95 additions and 89 deletions

View File

@ -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