Sha256: 29444831a42bf6206a4ec1256c5385868b7639dcdcfdfc044904f43bd6e3cd79
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require 'deas-erubis/source' module Deas; end module Deas::Erubis module TemplateHelpers def self.included(receiver) receiver.class_eval{ include Methods } end module Methods def partial(*args) @deas_source.partial(*args) end def capture_partial(*args, &content) _erb_buffer @deas_source.partial(*args, &Proc.new{ _erb_capture(&content) }) end private def _erb_capture(&content) begin # copy original buffer state orig_buf_value = _erb_bufvar instance_variable_set(_erb_bufvar_name, "\n") # evaluate the given content result = instance_eval(&content) new_buf_value = _erb_bufvar # return result if nothing buffered; otherwise return what was buffered new_buf_value == "\n" ? "\n#{result}" : new_buf_value ensure # reset buffer to original state instance_variable_set(_erb_bufvar_name, orig_buf_value) end end def _erb_buffer(content) _erb_bufvar << content end def _erb_bufvar instance_variable_get(_erb_bufvar_name) end def _erb_bufvar_name Deas::Erubis::Source::BUFVAR_NAME end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
deas-erubis-0.2.0 | lib/deas-erubis/template_helpers.rb |
deas-erubis-0.1.0 | lib/deas-erubis/template_helpers.rb |