Sha256: 52f3f808f7f4b5466c3dd2b104a92458caf9ddb4382cb1e32f9de4e84177fa46
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
# coding: utf-8 require 'erb' module ThinReports module Generator # @private class Pxd::PageRenderer include Pxd::Helper def initialize(format) @engine = ERB.new(read_layout(format)) @manager = {} @lists = {} end # @param [ThinReports::Core::Shape::Manager::Internal] manager # @return [String] def render(manager) @manager = manager @engine.result(binding) end def render_shape(id) return '' unless shape = @manager.final_shape(id) shape = shape.internal case when shape.type_of?(:tblock) render_tblock(shape) when shape.type_of?(:list) render_list(shape) when shape.type_of?(:text) render_text(shape) else render_basic(shape) end end alias_method :r, :render_shape private def render_basic(shape) tag(shape.svg_tag, shape.attributes) end def render_text(shape) content_tag(shape.svg_tag, shape.svg_content, shape.attribute, :escape => false) end def render_tblock(shape) value = h(shape.real_value) value = if shape.multiple? value.gsub(/\r\n|\n/, '<tBreak/>') else value.gsub(/\r\n|\n/, ' ') end content_tag(shape.svg_tag, value, shape.attributes, :escape => false) end def render_list(shape) renderer = @lists[shape.id] ||= Pxd::ListRenderer.new renderer.render(shape) end def read_layout(format) format.layout.gsub(/ x\-[a-z\d\-]+?=".*?"/, ''). gsub(/ class=".*?"/, '') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thinreports-0.6.0.pre3 | lib/thinreports/generator/pxd/page_renderer.rb |