Hello,
Is there another way to render html to the final page without using <%=
?
I tried using print, but the output was the Webrick console.
Thank you,
Brian Takita
Hello,
Is there another way to render html to the final page without using <%=
?
I tried using print, but the output was the Webrick console.
Thank you,
Brian Takita
You can try:
<% _erbout.concat "hello" %>
But note that this is kind of fragile, because ActionView may (theoretically) change the name of the concatenation variable ("_erbout").
- Jamis
On Jul 20, 2005, at 3:00 PM, Brian Takita wrote:
Hello,
Is there another way to render html to the final page without using <%=
?I tried using print, but the output was the Webrick console.
Brian Takita wrote:
Is there another way to render html to the final page without using <%=
?I tried using print, but the output was the Webrick console.
In ERb? No, that's how you do it. What's wrong with the syntax as it
exists?
Brian Takita wrote:
Hello,
Is there another way to render html to the final page without using <%=
?I tried using print, but the output was the Webrick console.
Thank you,
Brian Takita
From a controller method responsible for generating the page, you can use method render(:text => "content"), where "content" is an html content to show in the browser.
If you are looking for alternatives to ERB, you can try Amrita2 (http://amrita2.rubyforge.org/\). Or wait for my soon-to-be-released XHTML template expansion library called "Facial" (heavily influenced by Amrita2, see http://facial.rubyforge.org/wiki/wiki.pl for more information) ;-).
Gennady.
Not that this is the best way to do things, but I was thinking of:
<p<%= ' style="text-align: center"' if @has_style%><%= '...' if
@show_another_attribute%>>
Paragraph
</p>
vs:
<%
out = '<p'
out << ' style="text-align: center"' if @has_style
out << '...' if @show_another_attribute
out << '>'
out << Paragraph
out << '</p>
print out
%>
But now that I think about it, something like this would work out
better:
<%=
begin
out = '<p'
out << ' style="text-align: center"' if @has_style
out << '...' if @show_another_attribute
out << '>'
out << Paragraph
out << '</p>
end
%>
In article <42DEC37F.4030508@tonesoft.com>, gfb@tonesoft.com says...
Or wait for my soon-to-be-released
XHTML template expansion library called "Facial"
You many want to rethink the name if you expect this to become
popular... "facial" has a noun has some particularly bad connotations.
--
Jay Levitt |
Wellesley, MA | I feel calm. I feel ready. I can only
Faster: jay at jay dot fm | conclude that's because I don't have a
http://www.jay.fm | full grasp of the situation. - Mark Adler
This looks like a prime candidate for refactoring into a helper, actually:
<p<%= my_custom_p_attrs %>>Paragraph</p>
With the corresponding helper definition:
def my_custom_p_attrs
attrs = ""
attrs << %{ style="text-align: center"} if @has_style
attrs << %{ ...} if @show_another_attribute
attrs
end
- Jamis
On Jul 20, 2005, at 4:40 PM, Brian Takita wrote:
But now that I think about it, something like this would work out
better:<%=
begin
out = '<p'
out << ' style="text-align: center"' if @has_style
out << '...' if @show_another_attribute
out << '>'
out << Paragraph
out << '</p>
end
%>
Brian Takita wrote:
But now that I think about it, something like this would work out
better:<%=
begin
out = '<p'
out << ' style="text-align: center"' if @has_style
out << '...' if @show_another_attribute
out << '>'
out << Paragraph
out << '</p>
end
%>
I would wrap something like that in a helper method. Although you may
want to look into just using CSS classes as well.