Permalink
Browse files

Added option to ERB templates to swallow newlines by using <% if some…

…thing -%> instead of just <% if something %>

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@121 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 870632d commit 0052f41009cd0a52455779c04bb57e18cad5f9f8 @dhh dhh committed Dec 12, 2004
Showing with 33 additions and 1 deletion.
  1. +32 −0 actionpack/CHANGELOG
  2. +1 −1 actionpack/lib/action_view/base.rb
View
@@ -1,5 +1,37 @@
*SVN*
+* Added option to ERB templates to swallow newlines by using <% if something -%> instead of just <% if something %>. Example:
+
+ class SomeController < AbstractApplicationController
+ <% if options[:scaffold] %>
+ scaffold :<%= singular_name %>
+ <% end %>
+ helper :post
+
+ ...produces this on post as singular_name:
+
+ class SomeController < AbstractApplicationController
+
+ scaffold :post
+
+ helper :post
+
+ ...where as:
+
+ class SomeController < AbstractApplicationController
+ <% if options[:scaffold] -%>
+ scaffold :<%= singular_name %>
+ <% end -%>
+ helper :post
+
+ ...produces:
+
+ class SomeController < AbstractApplicationController
+ scaffold :post
+ helper :post
+
+ [This undocumented gem for ERb was uncovered by bitsweat]
+
* Fixed CgiRequest so that it'll now accept session options with Symbols as keys (as the documentation points out) [Suggested by Andreas]
* Added that render_partial will always by default include a counter with value 1 unless there is a counter passed in via the
@@ -251,7 +251,7 @@ def read_template_file(template_path)
end
def rhtml_render(template, binding)
- @@compiled_erb_templates[template] ||= ERB.new(template)
+ @@compiled_erb_templates[template] ||= ERB.new(template, nil, '-')
@@compiled_erb_templates[template].result(binding)
end

0 comments on commit 0052f41

Please sign in to comment.