diff options
-rw-r--r-- | ChangeLog.txt | 3 | ||||
-rw-r--r-- | ReleaseNote.txt | 142 | ||||
-rw-r--r-- | Rookbook.yaml | 7 | ||||
-rw-r--r-- | doc/users-guide.html | 123 | ||||
-rw-r--r-- | doc/users-guide.txt | 162 | ||||
-rw-r--r-- | website/index.txt | 35 | ||||
-rw-r--r-- | website/index.xhtml | 59 |
7 files changed, 399 insertions, 132 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index d6b0878..e688b19 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,9 @@ .?lastupdate: $Date$ .?version: $Rev$ +: Rev.79 (2007-05-23) + .- [update] CHANGES, ReleaseNote.txt, website/index.txt + : Rev.78 (2007-05-22) .- [enhance] add '-T' (don't expand tab characters) .- [enhance] add 'contrib/erubis-run.rb' (thanks to Andrew R Jackson) diff --git a/ReleaseNote.txt b/ReleaseNote.txt index 78adfb3..a24a572 100644 --- a/ReleaseNote.txt +++ b/ReleaseNote.txt @@ -1,3 +1,145 @@ +$ [ANN] Erubis 2.3.0 release - a fast and extensible eRuby implementation + +Hi all, + +I have just released Erubis 2.3.0. +http://www.kuwata-lab.com/erubis +http://www.kuwata-lab.com/erubis/CHANGES + +Erubis is another implementation of eRuby and it gives more speed +to Ruby on Rails application. + +Features: + * Very fast, almost three times faster than ERB and + even ten percent faster than eruby (implemented in C) + * File caching of converted Ruby script support, which + makes eRuby about 40-50 percent faster. + * Support multi-language + (Ruby,PHP,C,Java,Scheme,Perl,Javascript) + * Auto escaping support + * Auto trimming spaces around '<% %>' + * Embedded pattern changeable (default '<% %>') + * Context object available and easy to combine eRuby + template with YAML datafile or Ruby script + * Easy to extend in subclass + * Ruby on Rails support + * Mod_ruby support + +Installation is very easy. +.* Just type 'gem install -r erubis' if you have installed RubyGems. +.* Or download erubis_2.3.0.tar.bz2 and type 'ruby setup.rb'. + +See users' guide (erubis_2.3.0/doc/users-guide.html) +for details. + + +Enhancements: + + * New class 'Erubis::FastEruby' is added. + It is a subclass of Erubis::Eruby and includes InterpolationEnhancer. + Erubis::FastEruby is compatible with and faster than Erubis::Eruby. + + * New enhancer 'InterpolationEnhancer' is added. + This enhancer uses expression interpolation to eliminate method call + of String#<<. In the result, this enhancer makes Eruby a little faster. + -------------------- + ## Assume that input is '<a href="<%=url%>"><%=name%></a>'. + ## Eruby convert input into the following code. String#<< is called 5 times. + _buf << '<a href="'; _buf << (url).to_s; _buf << '">'; _buf << (name).to_s; _buf << '</a>'; + + ## When InterpolationEnhancer is used, String#<< is called only once. + _buf << %Q`<a href="#{url}">#{name}</a>`; + -------------------- + + * New enhancer 'ErboutEnhancer' is added. + ErboutEnhancer set '_erbout' as well as '_buf' to be compatible with ERB. + ==================== + $ cat ex.rhtml + <p>Hello</p> + $ erubis -x ex.rhtml + _buf = ''; _buf << '<p>Hello</p> + '; + _buf.to_s + $ erubis -xE Erbout ex.rhtml + _erbout = _buf = ''; _buf << '<p>Hello</p> + '; + _buf.to_s + ==================== + + * [experimental] + New enhancer 'DeleteIndentEnhancer' is added. + This enhancer deletes indentation of HTML file. + ==================== + $ cat ex.rhtml + <div> + <ul> + <% for item in ['AAA', 'BBB', 'CCC'] %> + <li><%= item %></li> + <% end %> + </ul> + </div> + $ erubis ex.rhtml + <div> + <ul> + <li>AAA</li> + <li>BBB</li> + <li>CCC</li> + </ul> + </div> + $ erubis -E DeleteIndent ex.rhtml + <div> + <ul> + <li>AAA</li> + <li>BBB</li> + <li>CCC</li> + </ul> + </div> + ==================== + + * Mod_ruby is supported (very thanks to Andrew R Jackson!). + See users-guide and 'contrib/erubis-run.rb' for details. + + * New command-line option '-X', '-N', '-U', and '-C' are added. + These are intended to be a replacement of 'notext' command. + = '-X' shows only ruby statements and expressions. + = '-N' adds line numbers. + = '-U' compress empty lines into a line. + = '-C' removes empty lines. + + +Changes: + + * 'helpers/rails_helper.rb' is changed to use ErboutEnhancer. + The following is an examle to use Erubis with Ruby on Rails. + File 'config/environment.rb': + ---------------------------------------- + require 'erubis/helpers/rails_helper' + #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby # or Erubis::FastEruby + #Erubis::Helpers::RailsHelper.init_properties = {} + #Erubis::Helpers::RailsHelper.show_src = false # set true for debugging + ---------------------------------------- + + * Command 'notext' has been removed. Use '-X', '-N', '-U', and '-C' + instead. + + * Tab characters in YAML file are expaneded automatically. + If you want not to expand tab characters, add command-line optio '-T'. + + * Benchmark scripts (benchmark/bench.*) are rewrited. + + * Users-guide (doc/users-guide.html) is updated. + + +Have fun! + +-- +regards, +kwatch + + + +.#-------------------------------------------------------------------------------- + $ [ANN] Erubis 2.2.0 release - a fast eRuby implementation Hi all, diff --git a/Rookbook.yaml b/Rookbook.yaml index 5a9bc2b..49a84df 100644 --- a/Rookbook.yaml +++ b/Rookbook.yaml @@ -129,7 +129,8 @@ recipes: end rm_f "#{dir}/test/Rookbook.yaml", "#{dir}/test/test.log" # - store 'benchmark/{bench.rb,bench_context.yaml}', 'benchmark/Makefile', dir + store 'benchmark/{bench.rb,bench_context.yaml}', + 'benchmark/templates/*', 'benchmark/Makefile', dir # Dir.glob('examples/*').each { |d| chdir d do sys 'make clean' end } store 'examples/**/*', dir @@ -163,8 +164,8 @@ recipes: end # chmod 0644, "#{dir}/**/*", :filetype=>'file' - chmod 0755, "#{dir}/{bin,contrib}/*", :filetype=>'file' - chmod 0644, "#{dir}/contrib/*.patch" + chmod 0755, "#{dir}/bin/*", :filetype=>'file' + chmod 0755, "#{dir}/contrib/{erubis,inline-require}", :filetype=>'file' - product: :duplicate method*: | diff --git a/doc/users-guide.html b/doc/users-guide.html index b8898f6..e49baa8 100644 --- a/doc/users-guide.html +++ b/doc/users-guide.html @@ -21,35 +21,6 @@ </p> <a name="preface"></a> <h2 class="section1">Preface</h2> -<p>Erubis is an implementation of eRuby. -It has the following features. -</p> -<ul type="disc"> -<li><a href="#topics-benchmark">Very fast</a>, almost three times faster than ERB and about ten percent faster than eruby (implemented in C) -</li> -<li><a href="#topics-caching">File caching of converted Ruby script support</a> -</li> -<li><a href="#tut-escape">Auto escaping support</a> -</li> -<li><a href="#tut-trim">Auto trimming spaces around '<% %>'</a> -</li> -<li><a href="#tut-pattern">Embedded pattern changeable</a> (default '<% %>') -</li> -<li><a href="#tut-pi">Enable to handle Processing Instructions (PI) as embedded pattern</a> (ex. '<?rb ... ?>') -</li> -<li><a href="#lang">Multi-language support</a> (Ruby/PHP/C/Java/Scheme/Perl/Javascript) -</li> -<li><a href="#tut-context">Context object available</a> and <a href="#tut-datafile">easy to combine eRuby template with YAML datafile</a> -</li> -<li><a href="#printenabled-enhancer">Print statement available</a> -</li> -<li><a href="#enhancer">Easy to expand and customize in subclass</a> -</li> -<li><a href="#topics-rails">Ruby on Rails support</a> -</li> -<li><a href="#topcs-modruby">mod_ruby support</a> -</li> -</ul> <p>Erubis is implemented in pure Ruby. It requires Ruby 1.8 or higher. </p> <a name="toc"></a> @@ -151,6 +122,8 @@ It has the following features. </li> <li><a href="#topics-rails">Ruby on Rails Support</a> </li> + <li><a href="#topics-php">NoTextEnhancer and NoCodeEnhancer in PHP</a> + </li> <li><a href="#topcs-modruby">Helper Class for mod_ruby</a> </li> <li><a href="#topics-benchmark">Benchmark</a> @@ -1243,6 +1216,11 @@ The following is an example to use some enhancers in command-line. <dd class="dd1"> [experimental] convert '<p><%= text %></p>' into '_buf << %Q`<p>#{text}</p>`'. </dd> +<dt class="dt1"> +<a href="#deleteindent-enhancer">DeleteIndentEnhancer</a> (language-independent)</dt> +<dd class="dd1"> + [experimental] delete indentation of HTML file and eliminate page size. +</dd> </dl> <p>If you required 'erubis/engine/enhanced', Eruby subclasses which include each enhancers are defined. For example, class BiPatternEruby includes BiPatternEnhancer. @@ -2472,6 +2450,93 @@ It is useful for debugging. <br> +<a name="topics-php"></a> +<h3 class="section2">NoTextEnhancer and NoCodeEnhancer in PHP</h3> +<p>NoTextEnhancer and NoCodEnahncer are quite useful not only for eRuby but also for PHP. +The former "drops" HTML text and show up embedded Ruby/PHP code +and the latter drops embedded Ruby/PHP code and leave HTML text. +</p> +<p>For example, see the following PHP script. +</p> +<a name="notext-example.php"></a> +<div class="program_caption"> +notext-example.php</div> +<pre class="program"><html> + <body> + <h3>List</h3> + <?php if (!$list || count($list) == 0) { ?> + <p>not found.</p> + <?php } else { ?> + <table> + <tbody> + <?php $i = 0; ?> + <?php foreach ($list as $item) { ?> + <tr bgcolor="<?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?>"> + <td><?php echo $item; ?></td> + </tr> + <?php } ?> + </tbody> + </table> + <?php } ?> + </body> +</html> +</pre> +<p>This is complex because PHP code and HTML document are mixed. +NoTextEnhancer can separate PHP code from HTML document. +</p> +<a name="notext-php.result"></a> +<div class="terminal_caption"> +example of using NoTextEnhancer with PHP file</div> +<pre class="terminal">$ erubis -l php --pi=php -N -E NoText --trim=false notext-example.php + 1: + 2: + 3: + 4: <?php if (!$list || count($list) == 0) { ?> + 5: + 6: <?php } else { ?> + 7: + 8: + 9: <?php $i = 0; ?> + 10: <?php foreach ($list as $item) { ?> + 11: <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + 12: <?php echo $item; ?> + 13: + 14: <?php } ?> + 15: + 16: + 17: <?php } ?> + 18: + 19: +</pre> +<p>In the same way, NoCodeEnhancer can extract HTML tags. +</p> +<a name="nocode-php.result"></a> +<div class="terminal_caption"> +example of using NoCodeEnhancer with PHP file</div> +<pre class="terminal">$ erubis -l php --pi=php -N -E NoCode --trim=false notext-example.php + 1: <html> + 2: <body> + 3: <h3>List</h3> + 4: + 5: <p>not found.</p> + 6: + 7: <table> + 8: <tbody> + 9: + 10: + 11: <tr bgcolor=""> + 12: <td></td> + 13: </tr> + 14: + 15: </tbody> + 16: </table> + 17: + 18: </body> + 19: </html> +</pre> +<br> + + <a name="topcs-modruby"></a> <h3 class="section2">Helper Class for mod_ruby</h3> <p>Thanks Andrew R Jackson, he developed 'erubis-run.rb' which enables you to use Erubis with mod_ruby. diff --git a/doc/users-guide.txt b/doc/users-guide.txt index e0318b2..90df4cb 100644 --- a/doc/users-guide.txt +++ b/doc/users-guide.txt @@ -10,20 +10,20 @@ release: $Release$ .$ Preface | preface* -Erubis is an implementation of eRuby. -It has the following features. -.* {{<Very fast|#topics-benchmark>}}, almost three times faster than ERB and about ten percent faster than eruby (implemented in C) -.* {{<File caching of converted Ruby script support|#topics-caching>}} -.* {{<Auto escaping support|#tut-escape>}} -.* {{<Auto trimming spaces around '<% %>'|#tut-trim>}} -.* {{<Embedded pattern changeable|#tut-pattern>}} (default '<% %>') -.* {{<Enable to handle Processing Instructions (PI) as embedded pattern|#tut-pi>}} (ex. '<?rb ... ?>') -.* {{<Multi-language support|#lang>}} (Ruby/PHP/C/Java/Scheme/Perl/Javascript) -.* {{<Context object available|#tut-context>}} and {{<easy to combine eRuby template with YAML datafile|#tut-datafile>}} -.* {{<Print statement available|#printenabled-enhancer>}} -.* {{<Easy to expand and customize in subclass|#enhancer>}} -.* {{<Ruby on Rails support|#topics-rails>}} -.* {{<mod_ruby support|#topcs-modruby>}} +.#Erubis is an implementation of eRuby. +.#It has the following features. +.#.* {{<Very fast|#topics-benchmark>}}, almost three times faster than ERB and about ten percent faster than eruby (implemented in C) +.#.* {{<File caching of converted Ruby script support|#topics-caching>}} +.#.* {{<Auto escaping support|#tut-escape>}} +.#.* {{<Auto trimming spaces around '<% %>'|#tut-trim>}} +.#.* {{<Embedded pattern changeable|#tut-pattern>}} (default '<% %>') +.#.* {{<Enable to handle Processing Instructions (PI) as embedded pattern|#tut-pi>}} (ex. '<?rb ... ?>') +.#.* {{<Multi-language support|#lang>}} (Ruby/PHP/C/Java/Scheme/Perl/Javascript) +.#.* {{<Context object available|#tut-context>}} and {{<easy to combine eRuby template with YAML datafile|#tut-datafile>}} +.#.* {{<Print statement available|#printenabled-enhancer>}} +.#.* {{<Easy to expand and customize in subclass|#enhancer>}} +.#.* {{<Ruby on Rails support|#topics-rails>}} +.#.* {{<mod_ruby support|#topcs-modruby>}} Erubis is implemented in pure Ruby. It requires Ruby 1.8 or higher. @@ -1131,6 +1131,8 @@ The following is the list of enhancers. [experimental] Enable you to add header and footer in eRuby script. .: {{<InterpolationEnhancer|#interpolation-enhancer>}} (only for Eruby) [experimental] convert '<p><%= text %></p>' into '_buf << %Q`<p>#{text}</p>`'. +.: {{<DeleteIndentEnhancer|#deleteindent-enhancer>}} (language-independent) + [experimental] delete indentation of HTML file and eliminate page size. If you required 'erubis/engine/enhanced', Eruby subclasses which include each enhancers are defined. @@ -1879,7 +1881,7 @@ You can use Erubis::FastEruby class instead of Erubis::Eruby class. InterpolationEnhancer is only for Eruby. -.$$ DeleteIndentEnhancer | interpolation-enhancer +.$$ DeleteIndentEnhancer | deleteindent-enhancer [experimental] DeleteIndentEnhancer deletes indentation of HTML file. @@ -2571,53 +2573,89 @@ It is useful for debugging. -.#.$$ NoTextEnhancer and NoCodeEnhancer in PHP | topics-php -.# -.#NoTextEnhancer and NoCodEnahncer are quite useful not only for eRuby but also for PHP. -.#The former "drops" HTML text and show up embedded Ruby/PHP code -.#and the latter drops embedded Ruby/PHP code and leave HTML text. -.# -.#For example, see the following PHP script. -.# -.#.? notext-example.php -.#.-------------------- notext-example.php -.#<html> -.# <body> -.# <h3>List</h3> -.# <?php if (!$list || count($list) == 0) { ?> -.# <p>not found.</p> -.# <?php } else { ?> -.# <table> -.# <tbody> -.# <?php $i = 0; ?> -.# <?php foreach ($list as $item) { ?> -.# <tr bgcolor="<?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?>"> -.# <td><?php echo $item; ?></td> -.# </tr> -.# <?php } ?> -.# </tbody> -.# </table> -.# <?php } ?> -.# </body> -.#</html> -.#.-------------------- -.# -.#This is complex because PHP code and HTML document are mixed. -.#NoTextEnhancer can separate PHP code from HTML document. -.# -.#.? example of using NoTextEnhancer with PHP file -.#.==================== -.#$ erubis -l php -E NoText -p '<\?php \?>' --trim=false notext-example.php | cat -n -.#.<<<:! erubis -l php -E NoText -p '<\?php \?>' --trim=false guide.d/notext-example.php | cat -n -.#.==================== -.# -.#In the same way, NoCodeEnhancer can extract HTML tags. -.# -.#.? example of using NoCodeEnhancer with PHP file -.#.==================== -.#$ erubis -l php -E NoCode -p '<\?php \?>' notext-example.php | cat -n -.#.<<<:! erubis -l php -E NoCode -p '<\?php \?>' guide.d/notext-example.php | cat -n -.#.==================== +.$$ NoTextEnhancer and NoCodeEnhancer in PHP | topics-php + +NoTextEnhancer and NoCodEnahncer are quite useful not only for eRuby but also for PHP. +The former "drops" HTML text and show up embedded Ruby/PHP code +and the latter drops embedded Ruby/PHP code and leave HTML text. + +For example, see the following PHP script. + +.? notext-example.php +.-------------------- notext-example.php +<html> + <body> + <h3>List</h3> + <?php if (!$list || count($list) == 0) { ?> + <p>not found.</p> + <?php } else { ?> + <table> + <tbody> + <?php $i = 0; ?> + <?php foreach ($list as $item) { ?> + <tr bgcolor="<?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?>"> + <td><?php echo $item; ?></td> + </tr> + <?php } ?> + </tbody> + </table> + <?php } ?> + </body> +</html> +.-------------------- + +This is complex because PHP code and HTML document are mixed. +NoTextEnhancer can separate PHP code from HTML document. + +.? example of using NoTextEnhancer with PHP file +.==================== notext-php.result +$ erubis -l php --pi=php -N -E NoText --trim=false notext-example.php + 1: + 2: + 3: + 4: <?php if (!$list || count($list) == 0) { ?> + 5: + 6: <?php } else { ?> + 7: + 8: + 9: <?php $i = 0; ?> + 10: <?php foreach ($list as $item) { ?> + 11: <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + 12: <?php echo $item; ?> + 13: + 14: <?php } ?> + 15: + 16: + 17: <?php } ?> + 18: + 19: +.==================== + +In the same way, NoCodeEnhancer can extract HTML tags. + +.? example of using NoCodeEnhancer with PHP file +.==================== nocode-php.result +$ erubis -l php --pi=php -N -E NoCode --trim=false notext-example.php + 1: <html> + 2: <body> + 3: <h3>List</h3> + 4: + 5: <p>not found.</p> + 6: + 7: <table> + 8: <tbody> + 9: + 10: + 11: <tr bgcolor=""> + 12: <td></td> + 13: </tr> + 14: + 15: </tbody> + 16: </table> + 17: + 18: </body> + 19: </html> +.==================== diff --git a/website/index.txt b/website/index.txt index 45bf6a6..684bfef 100644 --- a/website/index.txt +++ b/website/index.txt @@ -6,6 +6,7 @@ .$ News +.* [2007-05-23] {{<erubis_2.3.0|download.cgi>}} released. .* [2007-02-12] {{<erubis_2.2.0|download.cgi>}} released. .* [2006-09-28] {{<erubis-j_1.0.0|download.cgi>}} (porting to Java) released. .* [2006-09-24] {{<erubis_2.1.0|download.cgi>}} released. @@ -36,6 +37,7 @@ Erubis is a fast, secure, and very extensible implementation of eRuby. It has the following features. .* Very fast, almost three times faster than ERB and about ten percent faster than eruby (implemented in C). +.* File caching of converted Ruby script support. .* Auto escaping (sanitizing) support, it means that '<%= %>' can be escaped in default. It is desirable for web application. .* Spaces around '<% %>' are trimmed automatically only when '<%' is at the beginning of line and '%>' is at the end of line. @@ -53,6 +55,7 @@ It has the following features. .- Another embedded pattern support .- etc... .* Ruby on Rails support. +.* Mod_ruby support. eRuby means "embedded Ruby" in documents. Embedded patterns are '{{,<% {{/statement/}} %>,}}' and '{{,<%= {{/expression/}} %>,}}'. @@ -60,10 +63,12 @@ The following is an example of eRuby. '<% ... %>' means Ruby statement and '<%= .? example.eruby .-------------------- example.eruby -Hello <%= @user %>! -<% for item in @list %> - * <%= item %> -<% end %> +<h1>{{*<%= @title %>*}}</h1> +<ul> + {{*<% for item in @items %>*}} + <li><%= item %></td> + {{*<% end %>*}} +</ul> .-------------------- This will be compiled into Ruby program code. @@ -82,11 +87,11 @@ $ erubis -f data.yaml example.eruby .#+++ .-------------------- data.yaml -user: Erubis -list: - - aaa - - bbb - - ccc +title: Erubis Example +items: + - AAA + - BBB + - CCC .-------------------- .#--- @@ -102,25 +107,25 @@ You can use Erubis in Java with Rhino. .$ Download - .* Erubis (implemented in Ruby) + .* Erubis 2.3.0 (implemented in Ruby) .- if you have installed RubyGems, just type `{{,gem install -r erubis,}}' to install Erubis .- Or {{<download|download.cgi>}}.^ (Erubis requires {{<abstract|http://rubyforge.org/projects/abstract>}} library. Download and install it at first.) - .* Erubis-J (implemented in Java) {{!(New!)!}} + .* Erubis-J 1.0.0 (implemented in Java) {{!(New!)!}} .- {{<download|download.cgi?project=erubisj>}} .$ Documents .#.* {{<README|README.en.html>}} - .* Erubis (implemented in Ruby) + .* Erubis 2.3.0 (implemented in Ruby) .- {{<User's guide|users-guide.html>}} .- {{<CHANGES|CHANGES>}} .#.- {{<ReleaseNote|ReleaseNote.txt>}} - .* Erubis-J (implemented in Java) + .* Erubis-J 1.0.0 (implemented in Java) .- {{<User's guide|erubisj-users-guide.html>}} .#.- {{<Changelog|erubisj-ChangeLog>}} .#.- {{<ReleaseNote|erubisj-ReleaseNote.txt>}} .$ License - .* Erubis is released under MIT License. - .* Erubis-J is released under LGPL License. + .* Erubis is released under the MIT License. + .* Erubis-J is released under the LGPL License. diff --git a/website/index.xhtml b/website/index.xhtml index 452052f..c6b6844 100644 --- a/website/index.xhtml +++ b/website/index.xhtml @@ -24,6 +24,8 @@ <a name="News"></a> <h2 class="section">News</h2> <ul class="ul1"> +<li>[2007-05-23] <a href="download.cgi">erubis_2.3.0</a> released. +</li> <li>[2007-02-12] <a href="download.cgi">erubis_2.2.0</a> released. </li> <li>[2006-09-28] <a href="download.cgi">erubis-j_1.0.0</a> (porting to Java) released. @@ -59,6 +61,8 @@ It has the following features. <ul class="ul1"> <li>Very fast, almost three times faster than ERB and about ten percent faster than eruby (implemented in C). </li> +<li>File caching of converted Ruby script support. +</li> <li>Auto escaping (sanitizing) support, it means that '<%= %>' can be escaped in default. It is desirable for web application. </li> @@ -91,6 +95,8 @@ It has the following features. </li> <li>Ruby on Rails support. </li> +<li>Mod_ruby support. +</li> </ul> <p>eRuby means "embedded Ruby" in documents. Embedded patterns are '<code><% <em>statement</em> %></code>' and '<code><%= <em>expression</em> %></code>'. @@ -98,33 +104,40 @@ The following is an example of eRuby. '<% ... %>' means Ruby statement and </p> <a name="example.eruby"></a> <div class="program_caption">example.eruby</div> -<pre class="program">Hello <%= @user %>! -<% for item in @list %> - * <%= item %> -<% end %> +<pre class="program"><h1><strong><%= @title %></strong></h1> +<ul> + <strong><% for item in @items %></strong> + <li><%= item %></td> + <strong><% end %></strong> +</ul> </pre> <p>This will be compiled into Ruby program code. </p> <pre class="terminal">$ erubis -x example.eruby -_buf = ''; _buf << 'Hello '; _buf << ( @user ).to_s; _buf << '! -'; for item in @list - _buf << ' * '; _buf << ( item ).to_s; _buf << ' -'; end +_buf = ''; _buf << '<h1>'; _buf << ( @title ).to_s; _buf << '</h1> +<ul> +'; for item in @items + _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</td> +'; end + _buf << '</ul> +'; _buf.to_s </pre> <p>Or you can execute eRuby script directry. </p> <pre class="terminal">$ cat data.yaml -user: Erubis -list: - - aaa - - bbb - - ccc +title: Erubis Example +items: + - AAA + - BBB + - CCC $ erubis -f data.yaml example.eruby -Hello Erubis! - * aaa - * bbb - * ccc +<h1>Erubis Example</h1> +<ul> + <li>AAA</td> + <li>BBB</td> + <li>CCC</td> +</ul> </pre> <p>Erubis is implemented in Ruby and is now ported into Java. You can use Erubis in Java with Rhino. @@ -135,7 +148,7 @@ You can use Erubis in Java with Rhino. <a name="Download"></a> <h2 class="section">Download</h2> <ul class="ul1"> - <li>Erubis (implemented in Ruby) + <li>Erubis 2.3.0 (implemented in Ruby) <ul class="ul2"> <li>if you have installed RubyGems, just type `<code>gem install -r erubis</code>' to install Erubis </li> @@ -145,7 +158,7 @@ You can use Erubis in Java with Rhino. </li> </ul> </li> - <li>Erubis-J (implemented in Java) <span style="color:#FF0000">(New!)</span> + <li>Erubis-J 1.0.0 (implemented in Java) <span style="color:#FF0000">(New!)</span> <ul class="ul2"> <li><a href="download.cgi?project=erubisj">download</a> </li> @@ -158,7 +171,7 @@ You can use Erubis in Java with Rhino. <a name="Documents"></a> <h2 class="section">Documents</h2> <ul class="ul1"> - <li>Erubis (implemented in Ruby) + <li>Erubis 2.3.0 (implemented in Ruby) <ul class="ul2"> <li><a href="users-guide.html">User's guide</a> </li> @@ -166,7 +179,7 @@ You can use Erubis in Java with Rhino. </li> </ul> </li> - <li>Erubis-J (implemented in Java) + <li>Erubis-J 1.0.0 (implemented in Java) <ul class="ul2"> <li><a href="erubisj-users-guide.html">User's guide</a> </li> @@ -179,9 +192,9 @@ You can use Erubis in Java with Rhino. <a name="License"></a> <h2 class="section">License</h2> <ul class="ul1"> - <li>Erubis is released under MIT License. + <li>Erubis is released under the MIT License. </li> - <li>Erubis-J is released under LGPL License. + <li>Erubis-J is released under the LGPL License. </li> </ul> |