[#79440] [Ruby trunk Bug#13188] Reinitialize Ruby VM. — shyouhei@...
Issue #13188 has been updated by Shyouhei Urabe.
6 messages
2017/02/06
[#79441] Re: [Ruby trunk Bug#13188] Reinitialize Ruby VM.
— SASADA Koichi <ko1@...>
2017/02/06
On 2017/02/06 10:10, shyouhei@ruby-lang.org wrote:
[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>
Hi,
15 messages
2017/02/15
[#79541] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/15
Em 15-02-2017 05:05, Daniel Ferreira escreveu:
[#79543] Re: Immutable Strings vs Symbols
— Daniel Ferreira <subtileos@...>
2017/02/16
Hi Rodrigo,
[#79560] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/16
Em 15-02-2017 22:39, Daniel Ferreira escreveu:
[ruby-core:79458] [Ruby trunk Feature#8631] Add a new method to ERB to allow assigning the local variables from a hash
From:
nobu@...
Date:
2017-02-06 13:45:32 UTC
List:
ruby-core #79458
Issue #8631 has been updated by Nobuyoshi Nakada.
Another implementation:
```diff
diff --git a/lib/erb.rb b/lib/erb.rb
index 9483711024..9813b4dc71 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -887,6 +887,11 @@
# code evaluation.
#
def result(b=new_toplevel)
+ if b.respond_to?(:each_pair)
+ x = new_toplevel
+ b.each_pair {|k, v| x.local_variable_set(k, v)}
+ b = x
+ end
if @safe_level
proc {
$SAFE = @safe_level
```
----------------------------------------
Feature #8631: Add a new method to ERB to allow assigning the local variables from a hash
https://bugs.ruby-lang.org/issues/8631#change-62890
* Author: Rodrigo Rosenfeld Rosas
* Status: Assigned
* Priority: Normal
* Assignee: Masatoshi Seki
* Target version:
----------------------------------------
It would be interesting if ERB could allow a hash instead of a binding for processing the template.
We wouldn't have to do hacks like:
b = OpenStruct.new(hash).instance_eval{ binding }
---Files--------------------------------
feature-8631.pdf (27.7 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>