# IAre there some subtle bugs in ERB parsing?

**URL:** <https://www.ruby-forum.com/t/iare-there-some-subtle-bugs-in-erb-parsing/110055>\
**Category:** Ruby\
**Created:** [July 22, 2007, 6:14am UTC](https://www.ruby-forum.com/t/iare-there-some-subtle-bugs-in-erb-parsing/110055 "2007-07-22T06:14:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vfcforums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vfcforums](https://www.ruby-forum.com/u/vfcforums)\
**Post date:** [July 22, 2007, 6:14am UTC](https://www.ruby-forum.com/t/iare-there-some-subtle-bugs-in-erb-parsing/110055/1 "2007-07-22T06:14:44Z")

</div>

Is there any code in this ERB snippet that causes text after the EOF  
to be included in the template.

Unless my understanding of ERB is inadequate there has to be some bug in  
it.  
It has me at my wit’s end.

=============

template = ERB.new \<\<-EOF

```
# rsync push mode

#rsync_push_command check

# <%= rsync_push_command %>

# rsync_forced_command
# <%= rsync_forced_command %>
#

```

EOF

some program code here

=====  
After execution the text “some program code here” appears in the  
template’s output

Are there some circumstances under which ERB goes haywire?

Is there an alternate syntax to the ERB.NEW \<\<-EOF … EOF syntax for  
when the text is on multiple lines.

- Frank

---

<div class="post-metadata">

**Author:** ![vfcforums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vfcforums](https://www.ruby-forum.com/u/vfcforums)\
**Post date:** [July 22, 2007, 7:28am UTC](https://www.ruby-forum.com/t/iare-there-some-subtle-bugs-in-erb-parsing/110055/2 "2007-07-22T07:28:09Z")

</div>

On 22/07/2007, at 2:13 PM, Frank C. wrote:

> EOF  
> when the text is on multiple lines.
> 
> - Frank

Hi Frank,

I’m not that familiar with erb, but from what you’ve described I’m  
pretty sure the error’s with the text block not ending where you want  
it to.  
Are you using an editor with syntax highlighting? If so, this will  
show where the text block stops. The last EOF must have no whitespace  
before it, and a carriage return immediately after. It’s easy to get  
caught out with a stray space on the end of the line.

Cheers,  
Dave

---

<div class="post-metadata">

**Author:** ![vfcforums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vfcforums](https://www.ruby-forum.com/u/vfcforums)\
**Post date:** [July 22, 2007, 12:13pm UTC](https://www.ruby-forum.com/t/iare-there-some-subtle-bugs-in-erb-parsing/110055/3 "2007-07-22T12:13:00Z")

</div>

On 22/07/07, Frank C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> # rsync push mode
> 
> ```
> 
> - Frank

Thanks for the advice it was whitespace after the token

---

<div class="post-metadata">

**Author:** ![vfcforums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vfcforums](https://www.ruby-forum.com/u/vfcforums)\
**Post date:** [September 25, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/iare-there-some-subtle-bugs-in-erb-parsing/110055/4 "2007-09-25T23:02:37Z")

</div>

Sharon P. (aka Dave) wrote:

> On 22/07/2007, at 2:13 PM, Frank C. wrote:
> 
> > Is there an alternate syntax to the ERB.NEW \<\<-EOF … EOF syntax for  
> > when the text is on multiple lines.
> 
> The last EOF must have no whitespace before it […]

It can have white space before the token if you use the opening  
‘-’ option as Frank has, but I think you’ve identified the culprit  
here: white space /after/ the closing token.

Regards,

---

<div class="post-metadata">

**Author:** ![vfcforums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/85e7bf/32.png) [@vfcforums](https://www.ruby-forum.com/u/vfcforums)\
**Post date:** [September 25, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/iare-there-some-subtle-bugs-in-erb-parsing/110055/5 "2007-09-25T23:04:12Z")

</div>

On 22/07/2007, at 5:44 PM, Bil K. wrote:

> here: white space /after/ the closing token.  
> I’ve always used \<\<EOF and had no idea that \<\<- existed. Thanks.

Cheers,  
Dave
