Skip to content

Commit

Permalink
if ajax request don't put script tags around the output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Youch committed Apr 15, 2010
1 parent a1876bf commit bc2c934
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/page_controller.rb
Expand Up @@ -33,7 +33,7 @@ def paragraph #:nodoc:
@result = engine.run_paragraph(para,self,myself)

if @result
render :text => webiva_post_process_paragraph(render_paragraph(container.is_a?(SiteNode) ? container : container.site_node, revision, @result))
render :text => webiva_post_process_paragraph(render_paragraph(container.is_a?(SiteNode) ? container : container.site_node, revision, @result, :ajax => true))
else
render :nothing => true
end
Expand Down
13 changes: 11 additions & 2 deletions app/controllers/paragraph_feature.rb
Expand Up @@ -1797,7 +1797,9 @@ def webiva_feature(feature_name,data={})
end
opts = {}
opts[:site_feature_id] = data[:site_feature_id] if data.has_key?(:site_feature_id)
parse_feature(get_feature(feature_name,opts),parser_context)
feature = get_feature(feature_name,opts)
feature.body_html = single_feature(data[:partial_feature], feature.body_html) unless data[:partial_feature].blank?
parse_feature(feature,parser_context)
else
documenter = FeatureDocumenter.new(self) do |c|
yield c
Expand All @@ -1806,7 +1808,14 @@ def webiva_feature(feature_name,data={})
end
end


def single_feature(tag_name, feature_body)
if feature_body =~ /(<cms:#{tag_name}.*?\/cms:#{tag_name}>)/m
$1
else
feature_body
end
end

def get_feature(type,options = {}) #:nodoc:
if options.has_key?(:site_feature_id) && @feature_override = SiteFeature.find_by_id(options[:site_feature_id])
@feature_override
Expand Down
4 changes: 3 additions & 1 deletion lib/site_node_engine.rb
Expand Up @@ -297,7 +297,9 @@ def render_paragraph(site_node,revision,paragraph,opts = {})
paragraph.render_args[:locals] ||= {}
paragraph.render_args[:locals][:renderer] = paragraph.rnd unless paragraph.render_args[:locals][:renderer]
@paragraph = paragraph
str = "<script type='text/javascript'>" + render_to_string(paragraph.render_args) + "</script>"
str = render_to_string(paragraph.render_args)
str = "<script type='text/javascript'>" + str + "</script>" unless opts[:ajax]
str
elsif paragraph.render_args[:parent_rjs]
paragraph.render_args[:partial] = paragraph.render_args.delete(:parent_rjs)
paragraph.render_args[:locals] ||= {}
Expand Down

0 comments on commit bc2c934

Please sign in to comment.