Module: Ventilation::EsiHelper
- Included in:
- ApplicationHelper
- Defined in:
- lib/app/helpers/esi_helper.rb
Instance Method Summary collapse
-
#esi(resource, options = {}) ⇒ Object
Render resource on the edge.
- #esi_tag ⇒ Object
-
#esi_unsafe ⇒ Object
Render resource on the edge.
-
#expire(duration) ⇒ Object
Helper for setting expire headers.
Instance Method Details
#esi(resource, options = {}) ⇒ Object
Render resource on the edge
23 24 25 26 27 28 29 |
# File 'lib/app/helpers/esi_helper.rb', line 23 def esi(resource, = {}) if resource =~ URI.regexp %%<esi:include src="#{resource}" />% else %%<esi:include src="#{url_for .merge(:action => resource)}" />% end end |
#esi_tag ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/app/helpers/esi_helper.rb', line 20 def esi(resource, = {}) if resource =~ URI.regexp %%<esi:include src="#{resource}" />% else %%<esi:include src="#{url_for .merge(:action => resource)}" />% end end |
#esi_unsafe ⇒ Object
Render resource on the edge
54 55 56 57 58 59 60 |
# File 'lib/app/helpers/esi_helper.rb', line 54 def esi(resource, = {}) if resource =~ URI.regexp %%<esi:include src="#{resource}" />% else %%<esi:include src="#{url_for .merge(:action => resource)}" />% end end |
#expire(duration) ⇒ Object
Helper for setting expire headers.
Examples:
<%- expire 5.minutes -%>
<%- expire 30.seconds -%>
65 66 67 68 |
# File 'lib/app/helpers/esi_helper.rb', line 65 def expire(duration) headers['Cache-Control'] = "max-age=#{duration.to_i}" headers['Expires'] = duration.from_now.httpdate end |