Issue #8631 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).


I would already suggest a new name when I read about the problems with overriding the current method, so I would agree that 2 would be a better approach, I'm just not sure which name would be best. I like result_with_hash, but it could be result_from_locals or result_from_hash.

Or maybe ERB.new(str, locals: {a: b}).result?

----------------------------------------
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-65000

* Author: rosenfeld (Rodrigo Rosenfeld Rosas)
* Status: Feedback
* Priority: Normal
* Assignee: k0kubun (Takashi Kokubun)
* Target version: 2.5
----------------------------------------
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>