Class: SC::RenderEngine::Erubis
- Inherits:
-
Object
- Object
- SC::RenderEngine::Erubis
- Defined in:
- lib/sproutcore/render_engines/erubis.rb
Instance Method Summary collapse
- #capture(*args, &block) ⇒ Object
- #compile(input) ⇒ Object
- #concat(string, binding) ⇒ Object
-
#initialize(html_context) ⇒ Erubis
constructor
A new instance of Erubis.
Constructor Details
#initialize(html_context) ⇒ Erubis
Returns a new instance of Erubis.
12 13 14 |
# File 'lib/sproutcore/render_engines/erubis.rb', line 12 def initialize(html_context) @html_context = html_context end |
Instance Method Details
#capture(*args, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sproutcore/render_engines/erubis.rb', line 30 def capture(*args, &block) begin buffer = eval('_buf', block.binding) rescue buffer = nil end if buffer.nil? block.call(*args).to_s else pos = buffer.length block.call(*args) # get emitted data data = buffer[pos..-1] # remove from buffer buffer[pos..-1] = '' data end end |
#compile(input) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/sproutcore/render_engines/erubis.rb', line 16 def compile(input) begin require 'erubis' rescue raise "Cannot render ERB file because erubis is not installed. Try running 'sudo gem install erubis' and try again" end ::Erubis::Eruby.new.convert(input) end |
#concat(string, binding) ⇒ Object
26 27 28 |
# File 'lib/sproutcore/render_engines/erubis.rb', line 26 def concat(string, binding) eval('_buf', binding) << string end |