22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/ace/filters/template.rb', line 22
def call(item, content)
path = @layout || item.original_path.sub(/content\//, "")
if path.nil?
raise " You have to specify output_path of \#{self.inspect}\n\n Usage:\n\n class Post < Ace::Item\n before Ace::TemplateFilter, layout: \"posts.html\"\n end\n\n # OR:\n\n class Post < Ace::Item\n before Ace::TemplateFilter\n\n # And have #original_path set up (Ace does it by default,\n # but if you are using some custom code it might not work\n # out of the box).\n end\n EOF\n end\n\n parts = item.output_path.split(\".\")\n if parts.length == 2 # template.haml\n item.output_path = \"\#{parts[0]}.html\"\n elsif parts.length == 3 # template.html.haml or template.xml.haml\n item.output_path = \"\#{parts[0]}.\#{parts[1]}\"\n else\n 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.\"\n end\n\n template = TemplateInheritance::Template.new(path, Scope.new)\n return template.render(item: item)\nend\n".gsub(/ {10}/m, "")
|