Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're using the rails <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-capture" rel="nofollow">capture helper</a> but your syntax is wrong. I don't know why it's printing out <code>one</code>. In rails 3.4 it doesn't print out anything.</p> <p>Here's the right way to use it</p> <pre><code>&lt;% @number = capture do %&gt; three &lt;% end %&gt; this is some html and here is my &lt;%= @number %&gt; </code></pre> <p>The html that will be rendered is</p> <pre><code>this is some html and here is my three </code></pre> <p>Since your syntax is wrong I wouldn't worry about why "one" is showing up. Instead I'd focus more on using the capture helper correctly.</p> <p><hr /> <strong>Edit:</strong></p> <p>Your second (edited) example is not the same as your first one. Here it is with line numbers and a slight change to the last line so you can see what's going on.</p> <pre><code>1. &lt;% my_string = "" %&gt; 2. &lt;% my_string &lt;&lt; capture do %&gt; 3. Hello 4. &lt;% end %&gt; 5. before &lt;%= my_string %&gt; after </code></pre> <p>The result is <code>Hello before Hello after</code>. So line 3 is being rendered, then line 5 is being rendered with <code>my_string</code> containing the value <code>Hello</code>.</p> <p>If you change it to this</p> <pre><code> &lt;% my_string = "" %&gt; &lt;% my_string = capture do %&gt; &lt;!-- changed &lt;&lt; to = --&gt; Hello &lt;% end %&gt; before &lt;%= my_string %&gt; after </code></pre> <p>Then the result is <code>before Hello after</code>.</p> <p>So what does this all mean? When you use <code>&lt;&lt;</code> it's screwing up the <code>capture</code> method and it's rendering stuff that's inside the capture block even though normally you don't expect it to.</p> <p>Basically, you can't do what you're trying to do here, at least not with your current syntax.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload