Module: Fiveruns::Dash::Rails::TemplateContext
- Defined in:
- lib/fiveruns/dash/template_context.rb
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- RAILS_ROOT_RE =
/\A#{Regexp.quote RAILS_ROOT}/- GEM_REs =
Gem.path.map do |path| /\A#{Regexp.quote path}\/gems/ end
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 |
# File 'lib/fiveruns/dash/template_context.rb', line 4 def self.included(base) base.send(:include, InstanceMethods) base.alias_method_chain(:render, :fiveruns_dash_context) end |
.sanitize_view_path(path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fiveruns/dash/template_context.rb', line 15 def self.sanitize_view_path(path) path = if path[0..0] == '/' if path =~ RAILS_ROOT_RE trimmed = path.sub(RAILS_ROOT_RE, 'RAILS_ROOT') trimmed elsif (re = GEM_REs.find { |re| path =~ re }) trimmed = path.sub(re, 'GEMS') else path end else path end # Remove extensions, if any path.sub(/\.[^\/\\]*$/, '') end |