1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
|
# -*- coding: utf-8 -*-
# $Rev: 118 $
# $Release: 2.6.2 $
# copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
- release: 2.6.2
date: 2008-06-12
enhancements:
- |
Ruby 1.9 support.
bugfixes:
- |
Fixed a bug that it is not able to install Erubis on windows
(Thanks to Tim Morgan and Allen).
- release: 2.6.1
date: 2008-06-06
enhancements:
- |
Rails 2.1 support. (special thanks José Valim)
- release: 2.6.0
date: 2008-05-05
enhancements:
- |
Improved support of Ruby on Rails 2.0.2.
New class ActionView::TemplateHandlers::Erubis is defined and
registered as default handler of *.html.erb and *.rhtml.
- |
'<%% %>' and '<%%= %>' are converted into '<% %>' and '<%= %>' respectively.
This is for compatibility with ERB.
ex1.rhtml:
<ul>
<%% for item in @list %>
<li><%%= item %></li>
<%% end %>
</ul>
result:
$ erubis ex1.rhtml
<ul>
<% for item in @list %>
<li><%= item %></li>
<% end %>
</ul>
- |
'<%= -%>' removes tail spaces and newlines.
This is for compatibiliy with ERB when trim mode is '-'.
'<%= =%>' also removes tail spaces and newlines, and this is
Erubis-original enhancement (cooler than '<%= -%>', isn't it?).
ex2.rhtml:
<div>
<%= @var -%> # or <%= @var =%>
</div>
result (version 2.6.0):
$ erubis -c '{var: "AAA\n"}' ex2.rhtml
<div>
AAA
</div>
result (version 2.5.0):
$ erubis -c '{var: "AAA\n"}' ex2.rhtml
<div>
AAA
</div>
- |
Erubis::Eruby.load_file() now allows you to change cache filename.
ex.
eruby = Erubis::Eruby.load_file("ex3.rhtml",
:cachename=>'ex3.rhtml.cache')
- release: 2.5.0
date: 2008-01-30
enhancements:
- |
Ruby on Rails 2.0 support.
If you are using preprocessing, notice that _?('foo.id') will be NG
because it contains period ('.') character.
--------------------
<!-- NG in Rails 2.0 -->
[%= link_to 'Edit', edit_user_path(_?('@user.id')) %]
[%= link_to 'Show', @user %]
[%= link_to 'Delete', @user, :confirm=>'OK?', :method=>:delete %]
<!-- OK in Rails 2.0 -->
<%= user_id = @user.id %>
[%= link_to 'Edit', edit_user_path(_?('user_id')) %]
[%= link_to 'Show', :action=>'show', :id=>_?('user_id') %]
[%= link_to 'Delete', {:action=>'destroy', :id=>_?('user_id')},
{:confirm=>'OK?', :method=>:delete} %]
--------------------
- |
(experimental)
Rails form helper methods for preprocessing are added.
These helper methos are available with preprocessing.
ex. _form.rhtml
--------------------
Name: <%= text_field :user, :name %>
Name: [%= pp_text_field :user, :name %]
--------------------
preprocessed:
--------------------
Name: <%= text_field :user, :name %>
Name: <input id="stock_name" name="stock[name]" size="30" type="text" value="<%=h @stock.name%>" />
--------------------
Ruby code:
--------------------
_buf << '
Name: '; _buf << ( text_field :stock, :name ).to_s; _buf << '
Name: <input id="stock_name" name="stock[name]" size="30" type="text" value="'; _buf << (h @stock.name).to_s; _buf << '" />
';
--------------------
This shows that text_filed() is called every time when rendering,
but pp_text_filed() is called only once when loading template,
so pp_text_field() with prepocessing is much faster than text_field().
See User's guide for details.
http://www.kuwata-lab.com/erubis/users-guide.05.html#rails-formhelpers
#
- release: 2.4.1
date: 2007-09-25
enhancements:
- |
Add new section 'evaluate(context) v.s. result(binding)' to user's guide.
This section describes why Erubis::Eruby#evaluate(context) is recommended
rather than Erubis::Eruby#result(binding).
User's Guide > Other Topics > evaluate(context) v.s. result(binding)
http://www.kuwata-lab.com/erubis/users-guide.06.html#topics-context-vs-binding
- |
Add new command-line property '--docwrite={true|false}' to
Erubis::Ejavascript.
If this property is true then 'document.write(_buf.join(""));' is used
as postamble and if it is false then '_buf.join("")' is used.
Default is true for compatibility reason but it will be false in the
future release.
(This feature was proposed by D.Dribin. Thank you.)
bugfix:
- |
When using Erubis::Eruby#evaluate(), changing local variables in
templates have affected to variables accessible with TOPLEVEL_BINDING.
It means that if you change variables in templates, it is possible to
change variables in main program.
This was a bug and is now fixed not to affect to variables in main
program.
ex. template.rhtml
--------------------
<% for x in @items %>
item = <%= x %>
<% end %>
--------------------
ex. main-program.rb
--------------------
require 'erubis'
x = 10
items = ['foo', 'bar', 'baz']
eruby = Erubis::Eruby.new(File.read('template.rhtml'))
s = eruby.evaluate(:items=>items)
print s
$stderr.puts "*** debug: x=#{x.inspect}" #=> x="baz" (2.4.0)
#=> x=10 (2.4.1)
--------------------
- |
PercentLineEnhancer was very slow. Now performance problem is solved.
#
- release: 2.4.0
date: 2007-07-19
enhancements:
- |
Preprocessing is supported by Ruby on Rails helper.
Preprocessing makes Ruby on Rails application about 20-40 percent faster.
For example,
[%= link_to 'Show', :action=>'show', :id=>_?('@user.id') %]
is evaluate by preprocessor and expanded into the following
when template file is loaded.
<a href="/users/show/<%=@user.id%>">Show</a>
It means that link_to() is not called when template is rendered
and rendering speed will be much faster in the result.
See User's Guide for details.
- |
Erubis::Eruby#evaluate() (or Erubis::RubyEvaluator#evaluate()) now
creates Proc object from @src and eval it.
def evaluate(context=Context.new)
context = Context.new(context) if context.is_a?(Hash)
@_proc ||= eval("proc { #{@src} }", TOPLEVEL_BINDING, @filename || '(erubis)')
return context.instance_eval(&@_proc)
end
This makes evaluate() much faster when eruby object is reused.
- |
Erubis::Eruby#def_method() is supported.
This method defines ruby code as instance method or singleton metod.
require 'erubis'
s = "hello <%= name %>"
eruby = Erubis::Eruby.new(s)
filename = 'hello.rhtml'
## define instance method to Dummy class (or module)
class Dummy; end
eruby.def_method(Dummy, 'render(name)', filename) # filename is optional
p Dummy.new.render('world') #=> "hello world"
## define singleton method to an object
obj = Object.new
eruby.def_method(obj, 'render(name)', filename) # filename is optional
p obj.render('world') #=> "hello world"
This is equivarent to ERB#def_method().
- |
Erubis::XmlHelper.url_escape() and u() which is alias of url_escape()
are added.
This is equivarent to ERB#Util.url_escape().
bugfix:
- Help message was not shown when '-h' is specified. Fixed.
- 'def method()' was not availabe in template file. Fixed.
#
- release: 2.3.1
date: 2007-05-26
bugfix:
- A serious bug in 'helpers/rails_helper.rb' is fixed.
You must be update if you are using Erubis with Ruby on Rails.
#
- release: 2.3.0
date: 2007-05-23
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.
ex.
====================
$ 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.
ex.
====================
$ 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.
#
- release: 2.2.0
date: 2007-02-11
enhancements:
- |
Performance tuned up. Release 2.2.0 works about 8 percent faster
than 2.1.0.
As a result, Erubis works more than 10 percent faster than eruby.
(eruby is the extension module of eRuby written in C.)
- |
Support of Ruby on Rails improved.
If you want to use Erubis with Ruby on Rails, add the following code
into your 'config/environment.rb' and restart web server.
This will set Erubis as eRuby compiler in Ruby on Rails instead of ERB.
--------------------
require 'erubis/helpers/rails_helper'
#Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby
#Erubis::Helpers::RailsHelper.init_properties = {}
#Erubis::Helpers::RailsHelper.show_src = true
--------------------
Methods 'capture()' and 'content_for()' of ActionView::Helpers::CaptureHelper
are available. Methd ActionView::Helpers::TextHelper#concat() is also available.
If Erubis::Helpers::RailsHelper.show_src is ture, Erubis prints converted
Ruby code into log file (such as 'log/development.log').
- |
Erubis::Engine.load_file(filename) creates cache file (filename +
'.cache') automatically if cache file is old or not exist.
Caching makes Erubis about 40-50 percent faster.
ex.
--------------------
require 'erubis'
eruby = Erubis::Eruby.load_file('example.rhtml')
## cache file 'example.rhtml.cache' is created automatically
--------------------
- |
Command-line option '-f datafile' can take Ruby script ('*.rb')
as well as YAML file ('*.yaml' or '*.yml').
ex.
====================
$ cat context.rb
@title = 'Example'
@list = %w[AAA BBB CCC]
$ cat example.rhtml
<h1><%= @title %></h1>
<ul>
<% for item in @list %>
<li><%= item %></li>
<% end %>
</ul>
$ erubis -f context.rb example.rhtml
<h1>Example</h1>
<ul>
<li>AAA</li>
<li>BBB</li>
<li>CCC</li>
</ul>
====================
- |
New command-line option '-c context' support. It takes context string
in YAML inline style or Ruby code style.
ex. YAML inline style
====================
$ erubis -c '{title: Example, list: [AAA, BBB, CCC]}' example.rhtml
====================
ex. Ruby style
====================
$ erubis -c '@title="Example"; @list=%w[AAA BBB CCC]' example.rhtml
====================
- |
New command-line option '-z' (syntax checking) support. It is similar
to 'erubis -x file.rhtml | ruby -wc', but it can take several filenames.
ex.
====================
$ erubis -z app/views/*/*.rhtml
Syntax OK
====================
- |
New constant Erubis::VERSION added.
changes:
- |
Class Erubis::Eruby changed to include Erubis::StringBufferEnhancer
instead of Erubis::ArrayBufferEnhancer.
This is for Ruby on Rails support.
ex.
====================
$ cat example.rhtml
<ul>
<% for item in @list %>
<li><%= item %></li>
<% end %>
</ul>
$ erubis -x example.rhtml
_buf = ''; _buf << '<ul>
'; for item in @list
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
'; end
_buf << '</ul>
';
_buf.to_s
====================
- |
Erubis::StringBufferEnhancer#add_postamble() prints "_buf.to_s"
instead of "_buf".
This is useful for 'erubis -x file.rhtml | ruby -wc'.
- |
Command-line option '-T' is removed. Use '--trim=false' instead.
- |
License is changed to MIT License.
- |
Embedded pattern '<%- -%>' can be handled.
#
- release: 2.1.0
date: 2006-09-23
enhancements:
- |
Ruby on Rails support. Add the following code to
your 'app/controllers/application.rb' and restart web server.
--------------------
require 'erubis/helper/rails'
suffix = 'erubis'
ActionView::Base.register_template_handler(suffix, Erubis::Helper::RailsTemplate)
#Erubis::Helper::RailsTemplate.engine_class = Erubis::EscapedEruby ## or Erubis::PI::Eruby
#Erubis::Helper::RailsTemplate.default_properties = { :escape=>true, :escapefunc=>'h' }
--------------------
And rename your view template as 'xxx.erubis'.
If you got the "(eval):10:in `render': no block given" error,
use '@content_for_layout' instead 'yield' in your layout template.
- |
Another eRuby engine (PIEngine) support. This engine doesn't
break HTML design because it uses Processing Instructions (PI)
'<?rb .. ?>' as embedded pattern instead of '<% .. %>'.
example.rhtml
--------------------
<table>
<?rb @list.each_with_index do |item, i| ?>
<?rb klass = i % 2 == 0 ? 'odd' : 'even' ?>
<tr class="@{klass}@">
<td>@!{item}@</td>
</tr>
<?rb end ?>
</table>
--------------------
compile:
====================
$ erubis -x --pi example.rhtml
_buf = []; _buf << '<table>
'; @list.each_with_index do |item, i|
klass = i % 2 == 0 ? 'odd' : 'even'
_buf << ' <tr class="'; _buf << Erubis::XmlHelper.escape_xml(klass); _buf << '">
<td>'; _buf << (item).to_s; _buf << '</td>
</tr>
'; end
_buf << '</table>
';
_buf.join
====================
- |
Add new command 'notext' which remove text part from eRuby
script and leaves only Ruby code.
This is very useful for debug of eRuby script.
example2.rhtml
--------------------
<html>
<body>
<table>
<% @list.each_with_index do |item, i| %>
<% klass = i % 2 == 0 ? 'odd' : 'even' %>
<tr class="<%= klass %>">
<td><%== item %></td>
</tr>
<% end %>
</table>
</body>
</html>
--------------------
command line example:
====================
$ notext example2.rhtml
_buf = [];
@list.each_with_index do |item, i| ;
klass = i % 2 == 0 ? 'odd' : 'even' ;
_buf << ( klass ).to_s;
_buf << Erubis::XmlHelper.escape_xml( item );
end ;
_buf.join
$ notext -nc example2.rhtml
1: _buf = [];
4: @list.each_with_index do |item, i| ;
5: klass = i % 2 == 0 ? 'odd' : 'even' ;
6: _buf << ( klass ).to_s;
7: _buf << Erubis::XmlHelper.escape_xml( item );
9: end ;
13: _buf.join
====================
- |
Add new enhance 'NoCode' which removes ruby code from
eRuby script and leaves only HTML text part.
It is very useful to validate HTML of eRuby script.
command-line example:
====================
$ erubis -x -E NoCode example2.rhtml
<html>
<body>
<table>
<tr class="">
<td></td>
</tr>
</table>
</body>
</html>
====================
changes:
- License is changed to LGPL.
- Command-line property '--escape=name' is renamed to
'--escapefunc=name'.
- When command-line option '-l perl' is specified, function
'encode_entities()' is used ad escaping function which is
available wth HTML::Entities module.
bugfix:
- There is a certain pattern which makes Engine#convert()
too slow. Now Engne#convert() is fixed not to be slown.
- Command name is now displayed when '-h' is specified.
#
- release: 2.0.1
date: 2006-06-21
bugfix:
- some minor bugs are fixed
#
- release: 2.0.0
date: 2006-05-20
changes:
- module 'PrintEnhancer' is renamed to 'PrintEnabledEnahncer'
- module 'FastEnhancer' and class 'FastEruby' is obsolete because they are integrated into Eruby class
- Eruby#evaluate() calls instance_eval() instead of eval()
- XmlEruby.escape_xml() is moved to XmlHelper.escape_xml()
enhancements:
- multi programming language support (Ruby/PHP/C/Java/Scheme/Perl/Javascript)
- class Eruby runs very fast because FastEnhancer module is integrated into Eruby by default
- TinyEruby class (tiny.rb) is added
- module ArrayBufferEnhancer added
- module ArrayEnhancer added
- module BiPatternEnhancer added
- module EscapeEnhancer added
- module HeaderFooterEnhancer added
- module NoTextEnhancer added
- module PercentLineEnhancer added
- module PrintEnabledEnhancer added
- module PrintOutEnhancer added
- module SimplifyEnhancer added
- module StringBufferEnhancer added
- module StringIOEnhancer added
- command-line option '-b' (body only) added
- command-line option '-e' (escape) added
- command-line option '-l' (lang) added
- command-line option '-E' (enhancer) added
- command-line option '-I' (require path) added
- command-line option '-K' (kanji code) added
- command-line option '-S' (string to symbol) added
- command-line option '-B' (call result(binding())) added
#
- release: 1.1.0
date: 2006-03-05
enhancements:
- '<%# ... %>' is supported
- PrintEnhancer, PrintEruby, and PrintXmlEruby added
- release: 1.0.1
date: 2006-02-01
bugfixes:
- bin/erubis is available with RubyGems
#
- release: 1.0.0
date: 2006-02-01
bugfixes:
- first release
|