Module: RailsCom::TemplateRenderer

Defined in:
lib/rails_com/action_view/template_renderer.rb

Instance Method Summary collapse

Instance Method Details

#render_template(template, layout_name = nil, locals = nil) ⇒ Object

record where the view rendered from, main project or which engine used by view helper methods: js_load, css_load, js_ready



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rails_com/action_view/template_renderer.rb', line 7

def render_template(template, layout_name = nil, locals = nil)
  path = template.identifier

  result = path.match(/(?<=\/)[a-zA-Z0-9_-]+(?=\/app\/views)/)
  result = result.to_s.split('-').first.to_s + '/engine'

  engine = result.classify.safe_constantize

  @view.instance_variable_set(:@_rendered_from, engine.root) if engine

  super
end