From 5d777eb9e939106bb831c09a8e9e75f8191f143c Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Mon, 22 Jul 2013 15:14:53 +0200 Subject: [PATCH] With the move of path handling, Page#to_liquid can be simplified --- lib/jekyll/page.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 162a7fbe..4f48ffc7 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -7,6 +7,13 @@ module Jekyll attr_accessor :name, :ext, :basename attr_accessor :data, :content, :output + # Attributes for Liquid templates + ATTRIBUTES_FOR_LIQUID = %w[ + url + content + path + ] + # Initialize a new Page. # # site - The Site object. @@ -115,10 +122,10 @@ module Jekyll # # Returns the Hash representation of this Page. def to_liquid - self.data.deep_merge({ - "url" => self.url, - "content" => self.content, - "path" => self.path }) + further_data = Hash[ATTRIBUTES_FOR_LIQUID.map { |attribute| + [attribute, send(attribute)] + }] + data.deep_merge(further_data) end # The path to the source file