📄 5.2.htm
字号:
<P
class=docList><TT><I>Class</I></TT><TT>::</TT><TT><I>method</I></TT>
</P>
<LI>
<P
class=docList><TT><I>Class</I></TT><TT>#</TT><TT><I>method</I></TT>
</P>
<LI>
<P
class=docList><TT><I>Class</I></TT><TT>.</TT><TT><I>method</I></TT>
</P>
<LI>
<P
class=docList><TT><I>method</I></TT></P></LI></UL></DD></DL><A
name=ruby-CHP-5-SECT-2.2></A>
<H4 class=docSection2Title>5.2.2 eRuby</H4>
<P class=docText><A name=IXT-5-128952></A><A
name=IXT-5-128953></A>eRuby stands for embedded Ruby; it's a
tool that embeds fragments of Ruby code in other files such as
HTML files. Here's a sample eRuby file: </P><PRE>This is sample eRuby file<br>
The current time here is <%=Time.now%>.
<%[1,2,3].each{|x|print x,"<br>\n"}%></PRE>
<P class=docText>Here's the output from this sample file:</P><PRE>This is sample eRuby file<br>
The current time here is Wed Aug 29 18:54:45 JST 2001.
1
2
3</PRE>
<P class=docText>There are two eRuby implementations:</P><A
name=IXT-5-128954></A><A name=IXT-5-128955></A><A
name=IXT-5-128956></A><A name=IXT-5-128957></A><A
name=IXT-5-128958></A>
<DL class=docList>
<DT><I><SPAN class=docPubcolor>eruby</SPAN></I>
<DD>
<P class=docList><A name=IXT-5-128954></A><A
name=IXT-5-128955></A><A name=IXT-5-128956></A>The original
implementation of eRuby. eruby is available from <A
class=docLink href="http://www.modruby.net/"
target=_blank>http://www.modruby.net/</A>. </P>
<DT><I><SPAN class=docPubcolor>Erb</SPAN></I>
<DD>
<P class=docList><A name=IXT-5-128957></A><A
name=IXT-5-128958></A>A pure Ruby (subset) implementation of
eRuby. </P></DD></DL>
<P class=docText>eRuby is available from <A class=docLink
href="http://www2a.biglobe.ne.jp/~seki/ruby/erb-1.3.3.tar.gz"
target=_blank>http://www2a.biglobe.ne.jp/~seki/ruby/erb-1.3.3.tar.gz</A>;
The version number may be changed in the future.
Unfortunately, the supporting page <A class=docLink
href="http://www2a.biglobe.ne.jp/~seki/ruby/"
target=_blank>http://www2a.biglobe.ne.jp/~seki/ruby/</A> is in
Japanese, but you can tell how to use it from its source code.
</P>
<UL></UL></TD></TR></TBODY></TABLE>
<HR SIZE=1>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=15> </TD></TR>
<TR>
<TD class=v2 vAlign=top><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=print&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"
target=_new><IMG height=12 src="5.2.files/img_print.gif"
width=14 align=textTop border=0></A> <A class=v2
title="Printer-friendly version of this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=print&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"
target=_new>Print</A> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=email&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=9 hspace=3 src="5.2.files/img_email.gif" width=15
align=absMiddle border=0></A> <A class=v2
title="E-Mail this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=email&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1">E-Mail</A>
<A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=bookmark&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=14 hspace=3 src="5.2.files/img_bookmarks.gif" width=6
align=absMiddle border=0></A> <A class=v2
title="Add a bookmark about this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=bookmark&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1">Add
Bookmark</A></TD>
<TD class=v2 vAlign=top align=right> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-1&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=16 src="5.2.files/btn_prev.gif" width=56
align=absMiddle border=0></A> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-3&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=16 src="5.2.files/btn_next.gif" width=41
align=absMiddle border=0></A></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=right><A class=v1
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1#toppage">Top</A></TD></TR></TBODY></TABLE>
<P>[<A class=v2
href="http://proquest.safaribooksonline.com/0596002149/ruby-CHP-5-SECT-2">http://proquest.safaribooksonline.com/0596002149/ruby-CHP-5-SECT-2</A>]
</P></TD></TR></TBODY></TABLE></TD>
<TD align=middle> </TD></TR>
<TR>
<TD vAlign=bottom align=middle colSpan=3><BR>
<TABLE>
<TBODY>
<TR>
<TD class=v2 vAlign=center align=middle colSpan=4
height=25> <A class=v1
title="Information About Safari Tech Books Online"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=About">About
Safari</A> | <A class=v1
title="Safari Tech Books Online terms of service"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Terms">Terms
of Service</A> | <A class=v1
title="Safari Tech Books Online privacy policy"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Privacy">Privacy
Policy</A> | <A class=v1
title="Contacting Safari Tech Books Online"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Contact">Contact
Us</A> | <A class=v1
title="Safari Tech Books Online help"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Help">Help</A>
| <A class=v1
title="Submit a defect or enhancement request"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Submit">Submit
a Problem</A></TD></TR>
<TR>
<TD class=v2 vAlign=center align=middle height=20>Copyright © 2002
Safari Tech Books Online. All rights reserved.</TD></TR>
<TR vAlign=center>
<TD class=v2 vAlign=center align=middle colSpan=4 height=20>75
Arlington Street, Floor 3<BR>Boston, MA 02116<BR>800-775-7330</TD></TR>
<TR vAlign=center>
<TD class=v2 vAlign=center align=middle colSpan=4
height=5> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!--
(guidin)EE94E575-D563-4A31-90-AF-CA-B8-45-75-5B-41
(guidout)EE94E575-D563-4A31-90-AF-CA-B8-45-75-5B-41
(ip)147.8.179.17
(host)proquest.safaribooksonline.com
(portal)proquest
(ref)http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=toc&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1&srchText=
(base)?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-5-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1
(mode)section
(xmlid)0-59600-214-9/ruby-CHP-5-SECT-2
(key)7E6FA7863F875E5D371807B896A9188D02D5BE6122A762B263800A09E833AC01645EC3A55C82E53D
(user)29536/82393
(xsl)0ms
(lib)594ms
(xml)250ms
(xsl)219ms
(ent)0ms
(buf)0ms
(tot)1359ms
--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -