class Haml::TempleEngine

def compile(template)

def compile(template)
  initialize_encoding(template, options[:encoding])
  @precompiled = call(template)
end

def initialize_encoding(template, given_value)

def initialize_encoding(template, given_value)
  if given_value
    @encoding = given_value
  else
    @encoding = Encoding.default_internal || template.encoding
  end
end

def inspect_obj(obj)

def inspect_obj(obj)
  case obj
  when String
    %Q!"#{obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]}}"!
  when Symbol
    ":#{inspect_obj(obj.to_s)}"
  else
    obj.inspect
  end
end

def locals_code(names)

def locals_code(names)
  names = names.keys if Hash === names
  names.map do |name|
    # Can't use || because someone might explicitly pass in false with a symbol
    sym_local = "_haml_locals[#{inspect_obj(name.to_sym)}]"
    str_local = "_haml_locals[#{inspect_obj(name.to_s)}]"
    "#{name} = #{sym_local}.nil? ? #{str_local} : #{sym_local};"
  end.join
end

def precompiled

Returns:
  • (String) -
def precompiled
  encoding = Encoding.find(@encoding || '')
  return @precompiled.dup.force_encoding(encoding) if encoding == Encoding::ASCII_8BIT
  return @precompiled.encode(encoding)
end

def precompiled_method_return_value

This method exists so it can be monkeypatched to return modified values.
Returns the string used as the return value of the precompiled method.
def precompiled_method_return_value
  "_erbout"
end

def precompiled_method_return_value_with_haml_xss

def precompiled_method_return_value_with_haml_xss
  "::Haml::Util.html_safe(#{precompiled_method_return_value_without_haml_xss})"
end

def precompiled_with_ambles(local_names, after_preamble: '')

Returns:
  • (String) -
def precompiled_with_ambles(local_names, after_preamble: '')
  preamble = <<END.tr("\n", ';')
n
nd Haml::Helpers
lout = @haml_buffer = Haml::Buffer.new(haml_buffer, #{Options.new(options).for_buffer.inspect})
out = _hamlout.buffer
ter_preamble}
  postamble = <<END.tr("\n", ';')
ecompiled_method_return_value}
re
l_buffer = @haml_buffer.upper if @haml_buffer
  "#{preamble}#{locals_code(local_names)}#{precompiled}#{postamble}".dup
end

def precompiled_with_return_value

def precompiled_with_return_value
  "#{precompiled};#{precompiled_method_return_value}".dup
end