class ERB

def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')


A well messages pattie, breaded and fried.
Chicken Fried Steak -- 9.95

A well messages pattie, breaded and fried.
Chicken Fried Steak

_Generates_

puts listings.product + "\n" + listings.price

listings.build
listings = Listings.new
# setup template data

end
end
END_PRICE
<%= PRODUCT[:desc] %>
<%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@price").result b
END_PRODUCT
<%= PRODUCT[:desc] %>
<%= PRODUCT[:name] %>
ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@product").result b
# create and run templates, filling member data variables
b = binding
def build

end
@price = price
@product = product
def initialize( product = "", price = "" )

attr_reader :product, :price

:cost => 9.95 }
:desc => "A well messages pattie, breaded and fried.",
PRODUCT = { :name => "Chicken Fried Steak",
class Listings
# build data class

require "erb"

=== Example

output ends up. Pass the name of the variable to be used inside a String.
templates through the same binding and/or when you want to control where
its output in. This is useful when you need to run multiple ERB
_eoutvar_ can be used to set the name of the variable ERB will build up

- omit blank lines ending in -%>
> omit newline for lines ending in %>
<> omit newline for lines starting with <% and ending in %>
% enables Ruby code processing for lines beginning with %

modifiers, ERB will adjust its code generation as listed:
If _trim_mode_ is passed a String containing one or more of the following

the completed template when run.
An ERB object works by building a chunk of Ruby code that will output

Constructs a new ERB object with the template specified in _str_.
def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')
  # Complex initializer for $SAFE deprecation at [Feature #14256]. Use keyword arguments to pass trim_mode or eoutvar.
  if safe_level != NOT_GIVEN
    warn 'Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.', uplevel: 1
  end
  if legacy_trim_mode != NOT_GIVEN
    warn 'Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.', uplevel: 1
    trim_mode = legacy_trim_mode
  end
  if legacy_eoutvar != NOT_GIVEN
    warn 'Passing eoutvar with the 4th argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead.', uplevel: 1
    eoutvar = legacy_eoutvar
  end
  compiler = make_compiler(trim_mode)
  set_eoutvar(compiler, eoutvar)
  @src, @encoding, @frozen_string = *compiler.compile(str)
  @filename = nil
  @lineno = 0
  @_init = self.class.singleton_class
end