Skip to content

Instantly share code, notes, and snippets.

@russ
Created January 16, 2009 17:00
Show Gist options
  • Save russ/48000 to your computer and use it in GitHub Desktop.
Save russ/48000 to your computer and use it in GitHub Desktop.
def render_esi(path)
if Rails.env == 'development'
div_id = Digest::MD5.hexdigest(path + rand.to_s)
out = content_tag(:div, :id => div_id) do '' end
out += content_tag(:script, :type => 'text/javascript') do
'$.ajax({ type:"GET", url:"' + path + '", dataType:"html", success:function(html) { $("#' + div_id + '").html(html)
} });'
end
else
'<esi:include src="' + path + '" />'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment