dryml 1.3.0.pre11 → 1.3.0.pre12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre11
1
+ 1.3.0.pre12
@@ -4,6 +4,8 @@ ActionController::Base.class_eval do
4
4
  append_view_path Dryml::Railtie::PageTagResolver.new(self)
5
5
  end
6
6
 
7
+ attr_accessor :dryml_fallback_tag
8
+
7
9
  # dryml does not use layouts
8
10
  def action_has_layout?
9
11
  false
@@ -13,10 +15,6 @@ ActionController::Base.class_eval do
13
15
  @this
14
16
  end
15
17
 
16
- def dryml_fallback_tag(tag_name)
17
- @dryml_fallback_tag = tag_name
18
- end
19
-
20
18
  def call_dryml_tag(tag, options={})
21
19
  # TODO: Figure out what this bit is all about :-)
22
20
  if options[:with]
@@ -8,10 +8,10 @@ module Dryml
8
8
  end
9
9
 
10
10
  def find_templates(name, prefix, partial, details)
11
- tag_name = @dryml_fallback_tag || name.dasherize + '-page'
11
+ tag_name = @controller.dryml_fallback_tag || name.dasherize + '-page'
12
12
  text = @controller.call_dryml_tag(tag_name)
13
13
  return [] unless text
14
- [ActionView::Template.new(text, "dryml-tag:#{tag_name}", Dryml::Railtie::PageTagHandler, details)]
14
+ [ActionView::Template.new(text, "dryml-page-tag:#{tag_name}", Dryml::Railtie::PageTagHandler, details)]
15
15
  end
16
16
 
17
17
  end
data/lib/dryml.rb CHANGED
@@ -73,46 +73,49 @@ module Dryml
73
73
 
74
74
  def empty_page_renderer(view)
75
75
  controller_name = view.controller.class.name.underscore.sub(/_controller$/, "")
76
- page_renderer(view, [], "#{controller_name}/#{EMPTY_PAGE}")
76
+ page_renderer(view, "#{controller_name}/#{EMPTY_PAGE}" )
77
77
  end
78
78
 
79
79
  def call_render(view, local_assigns, identifier)
80
- page = view.request.fullpath
81
- renderer = page_renderer(view, local_assigns.keys, page, identifier)
80
+ page_path = view.request.fullpath
81
+ renderer = page_renderer(view, page_path, local_assigns.keys, identifier)
82
82
  this = view.controller.send(:dryml_context) || local_assigns[:this]
83
83
  view.instance_variable_set("@this", this)
84
84
  renderer.render_page(this, local_assigns).strip
85
85
  end
86
86
 
87
87
 
88
- def page_renderer(view, local_names=[], page=nil, filename=nil)
89
- if Rails.env.development?
90
- clear_cache
91
- Taglib.clear_cache
92
- end
88
+ def page_renderer(view, page_path, local_names=[], identifier=nil)
93
89
 
94
90
  prepare_view!(view)
95
- included_taglibs = ([APPLICATION_TAGLIB] + application_taglibs() + [subsite_taglib(page)] + controller_taglibs(view.controller.class)).compact
96
-
97
- if page.ends_with?(EMPTY_PAGE)
91
+ included_taglibs = ([APPLICATION_TAGLIB] + application_taglibs() + [subsite_taglib(page_path)] + controller_taglibs(view.controller.class)).compact
92
+
93
+ if identifier.blank? && ! page_path.ends_with?(EMPTY_PAGE)
94
+ opt = ActionController::Routing::Routes.recognize_path(page_path)
95
+ identifier = view.view_paths.find( opt[:action],
96
+ opt[:controller],
97
+ false,
98
+ view.lookup_context.instance_variable_get('@details')).identifier
99
+ end
100
+ if page_path.ends_with?(EMPTY_PAGE) || identifier.starts_with?('dryml-page-tag:')
98
101
  controller_class = view.controller.class
99
102
  @tag_page_renderer_classes[controller_class.name] ||=
100
- make_renderer_class("", page, local_names, DEFAULT_IMPORTS, included_taglibs)
101
- @tag_page_renderer_classes[controller_class.name].new(page, view)
103
+ make_renderer_class("", page_path, local_names, DEFAULT_IMPORTS, included_taglibs)
104
+ @tag_page_renderer_classes[controller_class.name].new(page_path, view)
102
105
  else
103
- mtime = File.mtime(filename)
104
- renderer_class = @renderer_classes[page]
106
+ mtime = File.mtime(identifier)
107
+ renderer_class = @renderer_classes[page_path]
105
108
 
106
109
  # do we need to recompile?
107
110
  if (!renderer_class || # nothing cached?
108
111
  (local_names - renderer_class.compiled_local_names).any? || # any new local names?
109
112
  renderer_class.load_time < mtime) # cache out of date?
110
- renderer_class = make_renderer_class(File.read(filename), filename, local_names,
113
+ renderer_class = make_renderer_class(File.read(identifier), identifier, local_names,
111
114
  DEFAULT_IMPORTS, included_taglibs)
112
115
  renderer_class.load_time = mtime
113
- @renderer_classes[page] = renderer_class
116
+ @renderer_classes[page_path] = renderer_class
114
117
  end
115
- renderer_class.new(page, view)
118
+ renderer_class.new(page_path, view)
116
119
  end
117
120
  end
118
121
 
@@ -172,7 +175,7 @@ module Dryml
172
175
  # Not sure why this isn't done for me...
173
176
  # There's probably a button to press round here somewhere
174
177
  for var in %w(@flash @cookies @action_name @_session @_request @request_origin
175
- @template @request @ignore_missing_templates @_headers @variables_added
178
+ @request @ignore_missing_templates @_headers @variables_added
176
179
  @_flash @response @template_class
177
180
  @_cookies @before_filter_chain_aborted @url
178
181
  @_response @template_root @headers @_params @params @session)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dryml
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1637175962
4
+ hash: -1637175961
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
- - pre11
11
- version: 1.3.0.pre11
10
+ - pre12
11
+ version: 1.3.0.pre12
12
12
  platform: ruby
13
13
  authors:
14
14
  - Tom Locke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-11 00:00:00 -04:00
19
+ date: 2010-10-14 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -43,13 +43,13 @@ dependencies:
43
43
  requirements:
44
44
  - - "="
45
45
  - !ruby/object:Gem::Version
46
- hash: -1637175962
46
+ hash: -1637175961
47
47
  segments:
48
48
  - 1
49
49
  - 3
50
50
  - 0
51
- - pre11
52
- version: 1.3.0.pre11
51
+ - pre12
52
+ version: 1.3.0.pre12
53
53
  type: :runtime
54
54
  version_requirements: *id002
55
55
  - !ruby/object:Gem::Dependency