class ActionView::Template::Handlers::ERB::Erubi

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/action_view/template/handlers/erb/erubi.rbs

class ActionView::Template::Handlers::ERB::Erubi < Erubi::Engine
  def add_code: (String code) -> false
  def add_expression: (String indicator, String code) -> String
  def add_postamble: (String _) -> String
  def add_text: (String text) -> Integer?
  def flush_newline_if_pending: (String src) -> Integer?
  def initialize: (String input, ?Hash properties) -> void
end

def add_code(code)

Experimental RBS support (using type sampling data from the type_fusion project).

def add_code: (String code) -> false

This signature was generated using 16 samples from 2 applications.

def add_code(code)
  flush_newline_if_pending(src)
  super
end

def add_expression(indicator, code)

Experimental RBS support (using type sampling data from the type_fusion project).

def add_expression: (String indicator, String code) -> String

This signature was generated using 27 samples from 2 applications.

def add_expression(indicator, code)
  flush_newline_if_pending(src)
  if (indicator == "==") || @escape
    src << bufvar << ".safe_expr_append="
  else
    src << bufvar << ".append="
  end
  if BLOCK_EXPR.match?(code)
    src << " " << code
  else
    src << "(" << code << ");"
  end
end

def add_postamble(_)

Experimental RBS support (using type sampling data from the type_fusion project).

def add_postamble: (String _) -> String

This signature was generated using 5 samples from 1 application.

def add_postamble(_)
  flush_newline_if_pending(src)
  super
end

def add_text(text)

Experimental RBS support (using type sampling data from the type_fusion project).

def add_text: (String text) -> Integer?

This signature was generated using 65 samples from 3 applications.

def add_text(text)
  return if text.empty?
  if text == "\n"
    @newline_pending += 1
  else
    src << bufvar << ".safe_append='"
    src << "\n" * @newline_pending if @newline_pending > 0
    src << text.gsub(/['\\]/, '\\\\\&')
    src << "'.freeze;"
    @newline_pending = 0
  end
end

def evaluate(action_view_erb_handler_context)

def evaluate(action_view_erb_handler_context)
  src = @src
  view = Class.new(ActionView::Base) {
    include action_view_erb_handler_context._routes.url_helpers
    class_eval("define_method(:_template) { |local_assigns, output_buffer| #{src} }", defined?(@filename) ? @filename : "(erubi)", 0)
  }.empty
  view._run(:_template, nil, {}, ActionView::OutputBuffer.new)
end

def flush_newline_if_pending(src)

Experimental RBS support (using type sampling data from the type_fusion project).

def flush_newline_if_pending: (String src) -> Integer?

This signature was generated using 63 samples from 2 applications.

def flush_newline_if_pending(src)
  if @newline_pending > 0
    src << bufvar << ".safe_append='#{"\n" * @newline_pending}'.freeze;"
    @newline_pending = 0
  end
end

def initialize(input, properties = {})

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: (String input, ?escape | FalseClass | trim | TrueClass | bufvar | String | preamble | String | postamble | String | escapefunc | String properties) -> void

This signature was generated using 10 samples from 1 application.

:nodoc: all
def initialize(input, properties = {})
  @newline_pending = 0
  # Dup properties so that we don't modify argument
  properties = Hash[properties]
  properties[:bufvar]     ||= "@output_buffer"
  properties[:preamble]   ||= ""
  properties[:postamble]  ||= "#{properties[:bufvar]}.to_s"
  properties[:escapefunc] = ""
  super
end