lib/bunto/layout.rb in bunto-3.0.0 vs lib/bunto/layout.rb in bunto-3.2.1
- old
+ new
@@ -9,10 +9,13 @@
attr_reader :name
# Gets the path to this layout.
attr_reader :path
+ # Gets the path to this layout relative to its base
+ attr_reader :relative_path
+
# Gets/Sets the extension of this layout.
attr_accessor :ext
# Gets/Sets the Hash that holds the metadata for this layout.
attr_accessor :data
@@ -35,10 +38,11 @@
@path = site.in_theme_dir(base, name)
else
@base_dir = site.source
@path = site.in_source_dir(base, name)
end
+ @relative_path = @path.sub(@base_dir, "")
self.data = {}
process(name)
read_yaml(base, name)
@@ -49,16 +53,8 @@
# name - The String filename of the layout file.
#
# Returns nothing.
def process(name)
self.ext = File.extname(name)
- end
-
- # The path to the layout, relative to the site source.
- #
- # Returns a String path which represents the relative path
- # from the site source to this layout
- def relative_path
- @relative_path ||= Pathname.new(path).relative_path_from(Pathname.new(@base_dir)).to_s
end
end
end