Sha256: 1f02f7bf45bc1255ba66dbce26744ea7ad0add8bfeffa914924eba9c53247cab
Contents?: true
Size: 885 Bytes
Versions: 1
Compression:
Stored size: 885 Bytes
Contents
require 'deas-erbtags/tag' module Deas::ErbTags module CaptureTag def self.included(receiver) receiver.class_eval{ include Tag, Method } end module Method def capture_tag(name, *args) opts = args.last.kind_of?(::Hash) ? args.pop : {} outvar = self.sinatra_call.settings.erb[:outvar] captured_content = begin orig_outvar = instance_variable_get(outvar) instance_variable_set(outvar, "\n") result = yield if block_given? if instance_variable_get(outvar) == "\n" "\n#{result}" else instance_variable_get(outvar) end ensure instance_variable_set(outvar, orig_outvar) end tag_markup = tag(name, "#{captured_content}\n", opts) instance_variable_get(outvar) << "#{tag_markup}\n" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
deas-erbtags-0.2.0 | lib/deas-erbtags/capture_tag.rb |