Skip to content

Commit

Permalink
further fixes to ERB in params behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
al2o3cr committed Oct 9, 2011
1 parent 8cf9783 commit 0164d93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions dryml/lib/dryml/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -726,22 +726,22 @@ def after_parameter_tag_hash_item(name, el, metadata_name)
def append_parameter_tag_hash_item(name, el, metadata_name)
":#{ruby_name name} => proc { [{}, { :default => proc { |#{param_content_local_name(name)}| new_context { %>" +
param_content_element(name) + children_to_erb(el) +
"<% } } } ] }"
"<% ; output_buffer } } } ] }"
end


def prepend_parameter_tag_hash_item(name, el, metadata_name)
":#{ruby_name name} => proc { [{}, { :default => proc { |#{param_content_local_name(name)}| new_context { %>" +
children_to_erb(el) + param_content_element(name) +
"<% } } } ] }"
"<% ; output_buffer } } } ] }"
end


def default_param_proc(el, containing_param_name=nil)
content = children_to_erb(el)
content = wrap_source_with_metadata(content, "param", containing_param_name,
element_line_num(el)) if containing_param_name
"proc { |#{param_content_local_name(el.dryml_name)}| new_context { %>#{content}<% } #{tag_newlines(el)}}"
"proc { |#{param_content_local_name(el.dryml_name)}| new_context { %>#{content}<% ; output_buffer } #{tag_newlines(el)}}"
end


Expand Down Expand Up @@ -789,7 +789,7 @@ def param_proc(el, metadata_name_suffix)
def replace_parameter_proc(el, metadata_name, content=nil)
content ||= wrap_replace_parameter(el, metadata_name)
param_name = el.dryml_name.sub(/^(before|after|append|prepend)-/, "")
"proc { |#{param_restore_local_name(param_name)}| new_context { %>#{content}<% } #{tag_newlines(el)}}"
"proc { |#{param_restore_local_name(param_name)}| new_context { %>#{content}<% ; output_buffer } #{tag_newlines(el)}}"
end


Expand Down
7 changes: 3 additions & 4 deletions dryml/lib/dryml/template_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,9 @@ def new_context
ctx = [ @_this, @_this_parent, @_this_field, @_this_type,
@_form_field_path, @_form_field_paths_by_object ]
@_this_type = nil
# TODO: remove THE HAX! We depend on the return value of this in some places, on the output buffer in others
inner_res = nil
outer_res = @view.with_output_buffer { inner_res = yield }
res = outer_res.blank? ? inner_res : outer_res
res = nil
outer_res = @view.with_output_buffer { res = yield }
Rails.logger.error("new_context: #{caller.first}") if !outer_res.blank? && outer_res.to_s != res.to_s
@_this, @_this_parent, @_this_field, @_this_type, @_form_field_path, @_form_field_paths_by_object = ctx
res.to_s
end
Expand Down

0 comments on commit 0164d93

Please sign in to comment.