From 6d9845a58b14a0dfba1120193bcd86ec9aaa8f97 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 26 Apr 2013 20:23:58 +0200 Subject: [PATCH] Refactor Post category instantiation --- lib/jekyll/post.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 4e337e96..46d64d3a 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -47,14 +47,8 @@ module Jekyll self.published = self.is_published - self.tags = self.data.pluralized_array("tag", "tags") - - if self.categories.empty? - self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase} - end - - self.tags.flatten! - self.categories.flatten! + self.setup_categories + self.setup_tags end def is_published @@ -65,6 +59,18 @@ module Jekyll end end + def setup_categories + if self.categories.empty? + self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase} + end + self.categories.flatten! + end + + def setup_tags + self.tags = self.data.pluralized_array("tag", "tags") + self.tags.flatten! + end + # Get the full path to the directory containing the post files def containing_dir(source, dir) return File.join(source, dir, '_posts')