Class: Erubis::Context

Overview

This is added to the Erubis Content class to allow the same helper methods to be used with both Markaby and Erubis.

Constant Summary

Constants included from Waves::Helpers::TagHelper

Waves::Helpers::TagHelper::ESCAPE_TABLE

Instance Method Summary collapse

Methods included from Waves::Helpers::NumberHelper

#number_with_delimiter

Methods included from Waves::Helpers::AssetHelper

#image_path, #image_tag

Methods included from Waves::Helpers::TagHelper

#escape_once, #h, #tag

Methods included from Waves::Helpers::UrlHelper

#link_to, #url_for

Instance Method Details

#<<(s) ⇒ Object



13
14
15
# File 'lib/renderers/erubis.rb', line 13

def <<(s) 
  eval("_buf", @binding).concat s # add to rendered output
end

#captureObject



17
18
19
20
21
22
# File 'lib/renderers/erubis.rb', line 17

def capture
  eval("_context.push(_buf); _buf = ''", @binding) #ignore output from that eval, will be added via "<<"
  result = Erubis::Eruby.new(yield).result @binding
  eval("_buf = _context.pop", @binding)
  result
end

#render(eruby) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/renderers/erubis.rb', line 24

def render(eruby)
  unless @binding
    @binding = binding
    eval("_buf = ''; _context = []", @binding)
  end
  eruby.result @binding
end