Fixed several bugs and release version 0.3.3.

master
Jakub Stastny aka botanicus 2011-06-05 20:01:42 +02:00
parent 35c3b9b914
commit 4970d59081
3 changed files with 32 additions and 7 deletions

View File

@ -51,8 +51,14 @@ module Ace
class Item class Item
def self.inherited(subclass) def self.inherited(subclass)
self.subclasses << subclass self.subclasses << subclass
subclass.before_filters.push(*self.before_filters)
subclass.after_filters.push(*self.after_filters) self.before_filters.each do |instance|
subclass.before_filters << instance.dup
end
self.after_filters.each do |instance|
subclass.after_filters << instance.dup
end
end end
def self.subclasses def self.subclasses

View File

@ -16,12 +16,31 @@ module Ace
end end
def initialize(options = Hash.new) def initialize(options = Hash.new)
@path = options[:layout] @layout = options[:layout] if options.has_key?(:layout)
end end
def call(item, content) def call(item, content)
if @path.nil? path = @layout || item.original_path.sub(/content\//, "") # We remove content/, because content is in TI paths.
@path = item.original_path.sub("content/", "") if path.nil?
raise <<-EOF.gsub(/ {10}/m, "")
You have to specify output_path of #{self.inspect}
Usage:
class Post < Ace::Item
before Ace::TemplateFilter, layout: "posts.html"
end
# OR:
class Post < Ace::Item
before Ace::TemplateFilter
# And have #original_path set up (Ace does it by default,
# but if you are using some custom code it might not work
# out of the box).
end
EOF
end end
parts = item.output_path.split(".") parts = item.output_path.split(".")
@ -33,7 +52,7 @@ module Ace
raise "Template can be named either with one suffix as template.haml or with two of them as template.html.haml resp. template.xml.haml." raise "Template can be named either with one suffix as template.haml or with two of them as template.html.haml resp. template.xml.haml."
end end
template = TemplateInheritance::Template.new(@path, Scope.new) template = TemplateInheritance::Template.new(path, Scope.new)
return template.render(item: item) return template.render(item: item)
end end
end end

View File

@ -1,5 +1,5 @@
# encoding: utf-8 # encoding: utf-8
module Ace module Ace
VERSION = "0.3.2" VERSION = "0.3.3"
end end