File: C:/Ruby27-x64/share/ri/2.7.0/system/ERB/new-c.ri
U:RDoc::AnyMethod[iI"new:ETI"
ERB::new;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"FConstructs a new ERB object with the template specified in _str_.;To:RDoc::Markup::BlankLine o;
; [I"KAn ERB object works by building a chunk of Ruby code that will output ;TI"%the completed template when run.;T@o;
; [I"OIf _trim_mode_ is passed a String containing one or more of the following ;TI">modifiers, ERB will adjust its code generation as listed:;T@o:RDoc::Markup::Verbatim; [ I"@% enables Ruby code processing for lines beginning with %
;TI"A<> omit newline for lines starting with <% and ending in %>
;TI",> omit newline for lines ending in %>
;TI"'- omit blank lines ending in -%>
;T:@format0o;
; [ I"M_eoutvar_ can be used to set the name of the variable ERB will build up ;TI"Fits output in. This is useful when you need to run multiple ERB ;TI"Ntemplates through the same binding and/or when you want to control where ;TI"Ooutput ends up. Pass the name of the variable to be used inside a String.;T@S:RDoc::Markup::Heading:
leveli: textI"Example;T@o;; ['I"require "erb"
;TI"
;TI"# build data class
;TI"class Listings
;TI"3 PRODUCT = { :name => "Chicken Fried Steak",
;TI"J :desc => "A well messages pattie, breaded and fried.",
;TI"# :cost => 9.95 }
;TI"
;TI"$ attr_reader :product, :price
;TI"
;TI"2 def initialize( product = "", price = "" )
;TI" @product = product
;TI" @price = price
;TI" end
;TI"
;TI" def build
;TI" b = binding
;TI"C # create and run templates, filling member data variables
;TI"a ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@product").result b
;TI"! <%= PRODUCT[:name] %>
;TI"! <%= PRODUCT[:desc] %>
;TI" END_PRODUCT
;TI"] ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@price").result b
;TI": <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
;TI"! <%= PRODUCT[:desc] %>
;TI" END_PRICE
;TI" end
;TI" end
;TI"
;TI"# setup template data
;TI"listings = Listings.new
;TI"listings.build
;TI"
;TI"3puts listings.product + "\n" + listings.price
;T;
0o;
; [I"_Generates_;T@o;; [
I"Chicken Fried Steak
;TI"0A well messages pattie, breaded and fried.
;TI"
;TI"!Chicken Fried Steak -- 9.95
;TI"/A well messages pattie, breaded and fried.;T;
0:
@fileI"lib/erb.rb;T:0@omit_headings_from_table_of_contents_below000[ I"z(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout');T@SFI"ERB;TcRDoc::NormalClass00