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
- if packet_binding.is_a? Orange::Packet
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
- string = false
35
- if temp
36
- string ||= read_if_exists('templates', file)
37
- @template_dirs.each do |templates_dir|
38
- string ||= read_if_exists(templates_dir, file)
39
- end unless string
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
- if context
43
- #Check for context specific overrides
44
- string ||= read_if_exists('views', resource, context+"."+file) if resource
45
- string ||= read_if_exists('views', context+"."+file)
46
- @view_dirs.each do |views_dir|
47
- string ||= read_if_exists(views_dir, resource, context+"."+file) if resource
48
- string ||= read_if_exists(views_dir, context+"."+file)
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
- # Check for standard views
53
- string ||= read_if_exists('views', resource, file) if resource
54
- string ||= read_if_exists('views', file)
55
- @view_dirs.each do |views_dir|
56
- string ||= read_if_exists(views_dir, resource, file) if resource
57
- string ||= read_if_exists(views_dir, file)
58
- end unless string
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
- # Check for default resource views
61
- string ||= read_if_exists('views', 'default_resource', file)
62
- @view_dirs.each do |views_dir|
63
- string ||= read_if_exists(views_dir, 'default_resource', file) if resource
64
- end unless string
65
- raise LoadError, "Couldn't find haml file '#{file}'" unless string
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
- haml_engine = Haml::Engine.new(string)
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 'route-'+model.id
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)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 0
9
- version: 0.4.0
7
+ - 5
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Haslem