orange 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,50 +21,62 @@ module Orange
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def haml(file, packet_binding, *vars, &block)
|
24
|
+
|
24
25
|
opts = vars.extract_options!
|
25
|
-
|
26
|
-
context = packet_binding['route.context'].to_s
|
27
|
-
end
|
26
|
+
# Initial info
|
28
27
|
temp = opts.delete(:template)
|
29
28
|
opts[:resource_name] = opts[:resource].orange_name.to_s if
|
30
29
|
opts[:resource] && opts[:resource].respond_to?(:orange_name)
|
31
30
|
resource = (opts[:resource_name] || '').downcase
|
32
|
-
opts.merge :orange => orange
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
32
|
+
if packet_binding.is_a? Orange::Packet
|
33
|
+
context = packet_binding['route.context'].to_s
|
34
|
+
unless temp
|
35
|
+
packet_binding['parser.haml-templates'] ||= {}
|
36
|
+
haml_engine = packet_binding['parser.haml-templates']["#{context}-#{resource}-#{file}"] || false
|
37
|
+
end
|
40
38
|
end
|
39
|
+
unless haml_engine
|
40
|
+
opts.merge :orange => orange
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end unless string
|
50
|
-
end
|
42
|
+
string = false
|
43
|
+
if temp
|
44
|
+
string ||= read_if_exists('templates', file)
|
45
|
+
@template_dirs.each do |templates_dir|
|
46
|
+
string ||= read_if_exists(templates_dir, file)
|
47
|
+
end unless string
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
if context
|
51
|
+
#Check for context specific overrides
|
52
|
+
string ||= read_if_exists('views', resource, context+"."+file) if resource
|
53
|
+
string ||= read_if_exists('views', context+"."+file)
|
54
|
+
@view_dirs.each do |views_dir|
|
55
|
+
string ||= read_if_exists(views_dir, resource, context+"."+file) if resource
|
56
|
+
string ||= read_if_exists(views_dir, context+"."+file)
|
57
|
+
end unless string
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
# Check for standard views
|
61
|
+
string ||= read_if_exists('views', resource, file) if resource
|
62
|
+
string ||= read_if_exists('views', file)
|
63
|
+
@view_dirs.each do |views_dir|
|
64
|
+
string ||= read_if_exists(views_dir, resource, file) if resource
|
65
|
+
string ||= read_if_exists(views_dir, file)
|
66
|
+
end unless string
|
66
67
|
|
67
|
-
|
68
|
+
# Check for default resource views
|
69
|
+
string ||= read_if_exists('views', 'default_resource', file)
|
70
|
+
@view_dirs.each do |views_dir|
|
71
|
+
string ||= read_if_exists(views_dir, 'default_resource', file) if resource
|
72
|
+
end unless string
|
73
|
+
raise LoadError, "Couldn't find haml file '#{file}'" unless string
|
74
|
+
|
75
|
+
haml_engine = Haml::Engine.new(string)
|
76
|
+
if packet_binding.is_a? Orange::Packet
|
77
|
+
packet_binding['parser.haml-templates']["#{context}-#{resource}-#{file}"] = haml_engine
|
78
|
+
end
|
79
|
+
end
|
68
80
|
out = haml_engine.render(packet_binding, opts, &block)
|
69
81
|
end
|
70
82
|
|
@@ -230,9 +230,9 @@ module Orange
|
|
230
230
|
|
231
231
|
def slug_for(model, props)
|
232
232
|
hash = model.attributes
|
233
|
-
return slug(model.title) if hash.has_key?(:title)
|
234
|
-
return slug(model.name) if hash.has_key?(:name)
|
235
|
-
return '
|
233
|
+
# return slug(model.title) if hash.has_key?(:title)
|
234
|
+
# return slug(model.name) if hash.has_key?(:name)
|
235
|
+
return 'page-'+model.id
|
236
236
|
end
|
237
237
|
|
238
238
|
def link_text_for(route)
|