Convertible: separate data validation out of #read

This commit is contained in:
Parker Moore 2016-01-15 15:52:54 -08:00
parent 948dcf2714
commit 89db3c6384
1 changed files with 10 additions and 3 deletions

View File

@ -57,15 +57,22 @@ module Jekyll
self.data ||= {}
validate_data!
validate_permalink!
self.data
end
def validate_data!
unless self.data.is_a?(Hash)
Jekyll.logger.abort_with "Fatal:", "Invalid YAML front matter in #{File.join(base, name)}"
end
end
def validate_permalink!
if self.data['permalink'] && self.data['permalink'].size == 0
Jekyll.logger.abort_with "Fatal:", "Invalid permalink in #{File.join(base, name)}"
end
self.data
end
# Transform the contents based on the content type.