Class: BetterHtml::BetterErb::ErubiImplementation

Inherits:
ActionView::Template::Handlers::ERB::Erubi
  • Object
show all
Includes:
RuntimeChecks
Defined in:
lib/better_html/better_erb/erubi_implementation.rb

Instance Method Summary collapse

Methods included from RuntimeChecks

#initialize, #validate!

Instance Method Details

#add_code(code) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/better_html/better_erb/erubi_implementation.rb', line 39

def add_code(code)
  flush_newline_if_pending(src)

  block_check(src, "<%#{code}%>")
  @parser.append_placeholder(code)
  super
end

#add_expression(indicator, code) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/better_html/better_erb/erubi_implementation.rb', line 31

def add_expression(indicator, code)
  if (indicator == "==") || @escape
    add_expr_auto_escaped(src, code, false)
  else
    add_expr_auto_escaped(src, code, true)
  end
end

#add_text(text) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/better_html/better_erb/erubi_implementation.rb', line 11

def add_text(text)
  return if text.empty?

  if text == "\n"
    @parser.parse("\n")
    @newline_pending += 1
  else
    src << "@output_buffer.safe_append='"
    src << "\n" * @newline_pending if @newline_pending > 0
    src << escape_text(text)
    src << "'.freeze;"

    @parser.parse(text) do |*args|
      check_token(*args)
    end

    @newline_pending = 0
  end
end