Hello,
I'm having a problem to output things in the write order with erb1.9
and lighttpd . I don't know if it's the normal comportement of erb but
this is how it works for me:
Content of my ERB file: test{<%= 1 %>2<% puts 3 %>}
On my web browser I get this output:
3
test{12}
puts or print comes before any text.. Do you wich function instead of
puts would print test{123}?
Do not combine puts with <%= %> output in your erb templates. puts prints to STDOUT, which may or may not be where your erb template is rendered. Just use <%= %>.
···
On 2010-06-10 07:59:42 -0700, Dominic Rose said:
Hello,
I'm having a problem to output things in the write order with erb1.9
and lighttpd . I don't know if it's the normal comportement of erb but
this is how it works for me:
Content of my ERB file: test{<%= 1 %>2<% puts 3 %>}
On my web browser I get this output:
3
test{12}
puts or print comes before any text.. Do you wich function instead of
puts would print test{123}?
puts or print comes before any text.. Do you wich function instead of
puts would print test{123}?
Thanks wery much
Do not combine puts with <%= %> output in your erb templates. puts
prints to STDOUT, which may or may not be where your erb template is
rendered. Just use <%= %>.
If I want to print something on the middle of a script I should do
"%><%= thing_to_print %><%" and that's what I was trying to avoid. Do
you know if I can do somthing like that ?
def print string
$__erbout.write string
end
Except that I don't know what is the erbout real identifier.
puts or print comes before any text.. Do you wich function instead of
puts would print test{123}?
Thanks wery much
Do not combine puts with <%= %> output in your erb templates. puts
prints to STDOUT, which may or may not be where your erb template is
rendered. Just use <%= %>.
If I want to print something on the middle of a script I should do
"%><%= thing_to_print %><%" and that's what I was trying to avoid. Do
you know if I can do somthing like that ?
def print string
$__erbout.write string
end
Except that I don't know what is the erbout real identifier.
Firstly:
As noted in the documentation, you can specify the erb out variable in
the call to ERB.new: http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html#M000301
If you don't have control over that, you can look at the source and
see what (if any) name they are supplying and use that.
Secondly:
After I asked to have "puts" work almost 5 years ago, people on the
list
helped create a patch to ERB to allow print and puts to concatenate to
this string. See [1] below. This was followed by some discussion
(again prompted by me) for a RCR to allow this to work. See [2] below.
The discussion there is probably worth reading before we dive into
this again.
On Jun 12, 7:52 am, Dominic Rose <ofusi...@gmail.com> wrote:
If I want to print something on the middle of a script I should do
"%><%= thing_to_print %><%" and that's what I was trying to avoid. Do
you know if I can do somthing like that ?
OK thank you that really helped. This is another piece to my puzzle.
Making work erb with lighttpd and without rails on both windows and
linux with a good error management and printing system is really hard,
not mentionning color syntaxing..