Class: ReActionView::Template::Handlers::Herb

Inherits:
ActionView::Template::Handlers::ERB
  • Object
show all
Includes:
LocalTemplate
Defined in:
lib/reactionview/template/handlers/herb.rb,
lib/reactionview/template/handlers/herb/herb.rb

Defined Under Namespace

Classes: Herb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(template, source, validation_mode: nil) ⇒ Object



13
14
15
# File 'lib/reactionview/template/handlers/herb.rb', line 13

def self.call(template, source, validation_mode: nil)
  new.call(template, source, validation_mode: validation_mode)
end

Instance Method Details

#call(template, source, validation_mode: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/reactionview/template/handlers/herb.rb', line 17

def call(template, source, validation_mode: nil)
  visitors = []

  if ::ReActionView.config.debug_mode_enabled? && local_template?(template)
    visitors << ::Herb::Engine::DebugVisitor.new(
      file_path: translate_path_for_editor(template.identifier),
      project_path: ::ReActionView.config.project_path
    )
  end

  config = {
    filename: template.identifier,
    project_path: Rails.root.to_s,
    validation_mode: validation_mode || ReActionView.config.validation_mode,
    content_for_head: reactionview_dev_tools_markup(template),
    visitors: visitors + ReActionView.config.transform_visitors,
  }

  erb_implementation.new(source, config).src
end