diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/erb.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/erb.rb b/lib/erb.rb index 4c29553a53..f367e32a97 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -889,6 +889,16 @@ class ERB end end + # Render a template on a new toplevel binding with local variables specified + # by a Hash object. + def result_with_hash(hash) + b = new_toplevel + hash.each_pair do |key, value| + b.local_variable_set(key, value) + end + result(b) + end + ## # Returns a new binding each time *near* TOPLEVEL_BINDING for runs that do # not specify a binding. |