<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kwatch</author_name>
  <author_url>https://blog.hatena.ne.jp/kwatch/</author_url>
  <blog_title>kなんとかの日記</blog_title>
  <blog_url>https://kwatch.hatenadiary.org/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>通常、ERB#result() には Binding を渡すけど、個人的にこれが大っ嫌い。なんでかというと、eRubyスクリプトを実行することで、メインプログラム内のローカル変数が勝手に変更されてしまうから。 つまりだな、 s = &lt;&lt;END &lt;% for item in list %&gt; &lt;p&gt;&lt;%= item %&gt;&lt;/p&gt; &lt;% end %&gt; END list = ['AAA', 'BBB', 'CCC'] require 'erb' item = 'foo' # ローカル変数を設定 print ERB.new(s).result(binding) p item #=&gt; &quot;CCC&quot; に変更さ…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fkwatch.hatenadiary.org%2Fentry%2F20080609%2F1213029123&quot; title=&quot; ERB で Binding を使うとローカル変数が勝手に変更されるという問題 - kなんとかの日記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2008-06-09 01:32:03</published>
  <title> ERB で Binding を使うとローカル変数が勝手に変更されるという問題</title>
  <type>rich</type>
  <url>https://kwatch.hatenadiary.org/entry/20080609/1213029123</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
