Class: ActionView::Base
- Inherits:
-
Object
- Object
- ActionView::Base
- Defined in:
- lib/masterview/rails_ext/action_view_erb_direct.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#compile_template?(template, file_name, local_assigns) ⇒ Boolean
:nodoc:.
-
#compile_template_pre_mv? ⇒ Object
Check whether compilation is necessary.
-
#read_template_file(template_path_with_ext, extension) ⇒ Object
:nodoc:.
-
#read_template_file_pre_mv ⇒ Object
checks for the existence of the template in MasterView first before using the rails file system based read_template_file.
-
#template_exists?(template_path, extension) ⇒ Boolean
:nodoc:.
-
#template_exists_pre_mv? ⇒ Object
checks for template existence, uses standard rails file based check first and if not found check MasterView paths because might not exist on file system.
Instance Method Details
#compile_template?(template, file_name, local_assigns) ⇒ Boolean
:nodoc:
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/masterview/rails_ext/action_view_erb_direct.rb', line 83 def compile_template?(template, file_name, local_assigns) #:nodoc: #MasterView::Log.debug { "compile_template? tpath=#{file_name} base=#{self.base_path}"} # templat is relative to Rails root mio_mtime = MasterView::RailsExt::ShortPathCalculator.calc_short_path_and_get_mtime(MasterView::ConfigSettings.rails_root_path, file_name, MasterView::IOMgr.erb) if mio_mtime method_key = file_name || template render_symbol = @@method_names[method_key] if @@compile_time[render_symbol] && supports_local_assigns?(render_symbol, local_assigns) if file_name && !@@cache_template_loading need_to_compile = (@@compile_time[render_symbol] < mio_mtime) # use mio.mtime instead of File.mtime MasterView::Log.debug{ 'compile_template? file_name = '+file_name+' compile?='+need_to_compile.to_s } need_to_compile end else true end else # use original file based mtime checking compile_template_pre_mv?(template, file_name, local_assigns) end end |
#compile_template_pre_mv? ⇒ Object
Check whether compilation is necessary. Since rails compile_template? is file based there was no easy way to hook into this, so much of this method had to be duplicated. If file_name exists in MasterView then check mtime from it otherwise defer to original code.
82 |
# File 'lib/masterview/rails_ext/action_view_erb_direct.rb', line 82 alias :compile_template_pre_mv? :compile_template? |
#read_template_file(template_path_with_ext, extension) ⇒ Object
:nodoc:
42 43 44 45 46 47 48 49 50 |
# File 'lib/masterview/rails_ext/action_view_erb_direct.rb', line 42 def read_template_file(template_path_with_ext, extension) #:nodoc: #MasterView::Log.debug{ "read_template_file tpath=#{template_path_with_ext} base=#{self.base_path}"} # template is relative to Rails root # if short_path found and exists in mio, then read and return otherwise use original read method MasterView::RailsExt::ShortPathCalculator.calc_short_path_and_retrieve(MasterView::ConfigSettings.rails_root_path, template_path_with_ext, MasterView::IOMgr.erb) || read_template_file_pre_mv(template_path_with_ext, extension) end |
#read_template_file_pre_mv ⇒ Object
checks for the existence of the template in MasterView first before using the rails file system based read_template_file
41 |
# File 'lib/masterview/rails_ext/action_view_erb_direct.rb', line 41 alias :read_template_file_pre_mv :read_template_file |
#template_exists?(template_path, extension) ⇒ Boolean
:nodoc:
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/masterview/rails_ext/action_view_erb_direct.rb', line 24 def template_exists?(template_path, extension) #:nodoc: found = template_exists_pre_mv?(template_path, extension) #MasterView::Log.debug{ "template_exists? tpath=#{template_path} base=#{self.base_path}"} # template is relative to view_base unless found short_path_no_ext = MasterView::RailsExt::ShortPathCalculator.calc_short_path(self.base_path, template_path) if short_path_no_ext short_path = short_path_no_ext+'.'+extension.to_s found = MasterView::IOMgr.erb.path(short_path).exist? end end found end |
#template_exists_pre_mv? ⇒ Object
checks for template existence, uses standard rails file based check first and if not found check MasterView paths because might not exist on file system
23 |
# File 'lib/masterview/rails_ext/action_view_erb_direct.rb', line 23 alias :template_exists_pre_mv? :template_exists? |