read_yaml to accept optional parameter to override defaults

This commit is contained in:
Shigeya Suzuki 2013-08-18 10:43:02 +09:00
parent 4cb24f4b87
commit 8b892ed735
1 changed files with 4 additions and 2 deletions

View File

@ -24,11 +24,13 @@ module Jekyll
# #
# base - The String path to the dir containing the file. # base - The String path to the dir containing the file.
# name - The String filename of the file. # name - The String filename of the file.
# opts - optional parameter to File.read, default at site configs
# #
# Returns nothing. # Returns nothing.
def read_yaml(base, name) def read_yaml(base, name, opts = {})
begin begin
opts = self.site ? self.site.file_read_opts : {} opts = (self.site ? self.site.file_read_opts : {}).merge(opts)
self.content = File.read(File.join(base, name), opts) self.content = File.read(File.join(base, name), opts)
if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m