Open
Description
When used with rails, erector currently wraps helper methods so that methods which return HTML, like link_to, will emit output instead.
This is not what rails developers expect, but it also creates problems which do not have easy solutions.
For example, consider the following HAML code to output some tabs with a vertical bar between the tabs.
- tabs = [link_to("File")]
- tabs << link_to("Edit") unless params[:readonly]
- tabs << link_to("Admin") if params[:admin]
= tabs.join(" | ").html_safe
This generates something like "File | Edit | Admin" (with the exact menu items depending on the parameters).
Translating to Erector looks like this:
tabs = [link_to("File")]
tabs << link_to("Edit") unless params[:readonly]
tabs << link_to("Admin") if params[:admin]
text tabs.join(" | ").html_safe
and the result is something like "FileEditAdmin |" because link_to emits rather than returning.
The rails helper to_sentence also suffers from this problems.
With the enclosed patch, the above erector code works.
diff --git a/lib/erector/rails3.rb b/lib/erector/rails3.rb
index 39a770b..ab9972b 100644
--- a/lib/erector/rails3.rb
+++ b/lib/erector/rails3.rb
@@ -48,7 +48,7 @@ module Erector
def def_simple_rails_helper(method_name)
module_eval <<-METHOD_DEF, __FILE__, __LINE__+1
def #{method_name}(*args, &block)
- text helpers.#{method_name}(*args, &block)
+ helpers.#{method_name}(*args, &block)
end
METHOD_DEF
end
Metadata
Metadata
Assignees
Labels
No labels