[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02795] Re: win OLE / eRuby

From: Masatoshi SEKI <m_seki@...>
Date: 2000-05-12 17:30:18 UTC
List: ruby-talk #2795
> Also, the same question for eRuby - it seems pretty straightforward, but
> I can't find any English documentation, so more examples would be
> great.

Table.rhtml writes a table of alternate white and gray rows.
This example lists current directory files as follows. 
  list = Dir.glob('*').sort
Replace it with your query code, in your application.

 % ruby erb.rb table.rhtml > table.html		# erb
 % eruby table.rhtml > table.html		# eruby

-- table.rhtml ---
<HTML>
<HEAD>
<TITLE>401 Unauthorized</TITLE>
</HEAD>
<BODY>
<% 
  def h(s)
    s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
  end

  class BGAttr
    def initialize(colors = ["#eeeeee", "#ffffff"])
      @colors = colors
      @cur = -1
    end

    def to_s
      @cur = (@cur+1) % @colors.size
      "bgcolor=\"#{@colors[@cur]}\""
    end
  end

  list = Dir.glob('*').sort
%>
<H2>Dir.glob('*')</H2>
<TABLE bgcolor="white" rules="none" frame="void">
<% 
  bgattr = BGAttr.new
  list.each do |v|
%>
<TR <%= bgattr %>><TD><%=h v %>
<%
  end
%>
</TABLE>
<HR>
<ADDRESS><A href="mailto:m_seki@mva.biglobe.ne.jp">Masatoshi  SEKI</A><ADDRESS>
</BODY>


In This Thread