~ubuntu-branches/ubuntu/saucy/ruby-erubis/saucy

« back to all changes in this revision

Viewing changes to test/data/users-guide/main_program1.rb

  • Committer: Package Import Robot
  • Author(s): Laurent Bigonville
  • Date: 2012-01-26 15:15:58 UTC
  • Revision ID: package-import@ubuntu.com-20120126151558-9u7mnf9ooqnw3bwz
Tags: upstream-2.7.0
ImportĀ upstreamĀ versionĀ 2.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'erubis'
 
2
eruby = Erubis::Eruby.new(File.read('template1.rhtml'))
 
3
items = ['foo', 'bar', 'baz']
 
4
x = 1
 
5
## local variable 'x' and 'eruby' are passed to template as well as 'items'!
 
6
print eruby.result(binding())    
 
7
## local variable 'x' is changed unintendedly because it is changed in template!
 
8
puts "** debug: x=#{x.inspect}"  #=> "baz"