Sha256: 987d0fee3223f3926e35b43d919005c14d7e2e3033676781e20470880ac2ceac
Contents?: true
Size: 1.25 KB
Versions: 5
Compression:
Stored size: 1.25 KB
Contents
module Gnip class Template < ERB def Template.for(*args, &block) new(*args, &block) end def initialize(*args, &block) args, options = Gnip.args_for(args) @context = options.getopt(:context, options.getopt(:object)) string = args.shift || block.call super(Gnip.util.unindent(string), safe_mode=nil, trim_mode='%') end def expand context = nil, &block context ||= block.binding if block context ||= @context raise ArgumentError, 'no context' unless context context = context.instance_eval('binding') unless context.respond_to?('binding') block.call(self) if block result(context) end class Xml < Template Declaration = '<?xml version="1.0" encoding="UTF-8"?>' def initialize(string = '', options = {}, &block) Gnip.optify!(options) declaration = options.getopt(:declaration) case declaration when TrueClass, FalseClass, NilClass declaration = Declaration if declaration else declaration = declaration.to_s end string = "#{ declaration }\n#{ Gnip.util.unindent(string) }" if declaration super(string, options, &block) end end def Template.xml() Xml end end end
Version data entries
5 entries across 5 versions & 2 rubygems
Version | Path |
---|---|
gnip-gnip-1.1.1 | lib/gnip/template.rb |
gnip-0.4.2 | lib/gnip/template.rb |
gnip-1.0.0 | lib/gnip/template.rb |
gnip-1.1.2 | lib/gnip/template.rb |
gnip-1.1.1 | lib/gnip/template.rb |