Convertible: separate data validation out of #read
This commit is contained in:
parent
948dcf2714
commit
89db3c6384
|
@ -57,15 +57,22 @@ module Jekyll
|
||||||
|
|
||||||
self.data ||= {}
|
self.data ||= {}
|
||||||
|
|
||||||
|
validate_data!
|
||||||
|
validate_permalink!
|
||||||
|
|
||||||
|
self.data
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_data!
|
||||||
unless self.data.is_a?(Hash)
|
unless self.data.is_a?(Hash)
|
||||||
Jekyll.logger.abort_with "Fatal:", "Invalid YAML front matter in #{File.join(base, name)}"
|
Jekyll.logger.abort_with "Fatal:", "Invalid YAML front matter in #{File.join(base, name)}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_permalink!
|
||||||
if self.data['permalink'] && self.data['permalink'].size == 0
|
if self.data['permalink'] && self.data['permalink'].size == 0
|
||||||
Jekyll.logger.abort_with "Fatal:", "Invalid permalink in #{File.join(base, name)}"
|
Jekyll.logger.abort_with "Fatal:", "Invalid permalink in #{File.join(base, name)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
self.data
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Transform the contents based on the content type.
|
# Transform the contents based on the content type.
|
||||||
|
|
Loading…
Reference in New Issue