From: Douglas Seifert Date: 2009-05-10T07:45:51+09:00 Subject: Re: CGI help --000e0cd40200b32e750469828194 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit > > cgi.form('post') { > cgi.textarea() + > cgi.submit > } > The above works because the interpreter finds something on the next line to add to the result of cgi.textarea(). > > > This produces kEND errors: > > cgi.form('post') { > if true > cgi.textarea() + > else > cgi.textarea() + > > cgi.submit > } The interpreter sees that + at the end of the line in the first branch of the if statement and gets confused looking for something to add it to. It would be nice if it could figure out that you wanted to add it to the result of the statement that comes after the if statement, but that is not how it works. You would need to do something like like this to get it to work: (condition ? cgi.textarea() : cgi.textarea()) + cgi.submit > You can't do this in plain ruby: > > str = "hello" + > " goodbye" > The above works just fine. You end up with str being a reference to "hello goodby". > > But the cgi syntax allows you to add things together like that. > There is nothing magical about the cgi syntax. All that is happening is that String objects are getting added together. To get it to work, you have to ensure that the blocks passed to the various cgi methods end up evaluating to the string you want the tag created by the block's method to contain. You do that by making the last statement evaluated in the block be the string you want as content. -Doug Seifert --000e0cd40200b32e750469828194--