syntax error in RJS

I'm new to Ruby on Rails and came across a problem I could not solve
alone.
I've a pretty simple RJS file that looks like the following:

3.times do
  page.insert_html :bottom, 'messages', 'test'
end
page.call 'updateMessageWindow'

However this snippet gives a syntax error:

ActionView::TemplateError (compile error
D:/Eigene
Dateien/Programming/Web/AjaxChat/app/views/chat/update.js.rjs:1: syntax
error, unexpected tIDENTIFIER, expecting kEND
3.times do
  page.insert_html :bottom, 'messages', 'test'
end
page.call 'updateMessageWindow'
                                                                  ^) on
line #1 of chat/update.js.rjs:
1: 3.times do
  page.insert_html :bottom, 'messages', 'test'
end
page.call 'updateMessageWindow'

What is wrong with it? If I remove the last line (page.call
'updateMessageWindow') everything works as expected.

Hi, you forgot the block local variable. Thus, the above should have been developed

as follows:

3.times do |page|

page.insert_html :bottom, ‘messages’, ‘test’
end
page.call ‘updateMessageWindow’

Good luck,

-Conrad

That's not true. You don't need the block variable (and in your
example it's doubly bad because you would be overwriting the magic
page variables with the integers 0 to 2.

What's the whole of the rjs file ?

Fred

Frederick Cheung wrote:

�page.insert_html :bottom, 'messages', 'test'
end
page.call 'updateMessageWindow'

That's not true. You don't need the block variable (and in your
example it's doubly bad because you would be overwriting the magic
page variables with the integers 0 to 2.

What's the whole of the rjs file ?

Fred

Right, as it's an rjs file it is automatically wrapped inside a block.
After struggling a day with the code and not being able to detect any
syntax error whatsoever I checked the encoding of the line endings. To
my surprise they were encoded as carriage returns (CR, Mac style).
Changing them to Linux (LF) or Windows (CR+LF) style solved the problem
and the parser was happy again. I have no clue why my editor (intype)
suddenly inserted CRs instead of line feeds (other files I've written
with the same editor have a correct encoding of the line endings).
To conclude, the syntax error hadn't anything to do with RJS templates
in special.