class Grape::Axlsx::Renderer
Attributes
template[R]
view_path[R]
Public Class Methods
new(view_path, template)
click to toggle source
# File lib/grape/axlsx/renderer.rb, line 6 def initialize(view_path, template) @view_path, @template = view_path, template end
Public Instance Methods
render(scope)
click to toggle source
# File lib/grape/axlsx/renderer.rb, line 10 def render(scope) unless view_path raise "Use Rack::Config to set 'api.tilt.root' in config.ru" end context = scope.instance_eval { binding } eval "xlsx_package = ::Axlsx::Package.new; #{template_content}; xlsx_package.to_stream.string;", context end
Private Instance Methods
file()
click to toggle source
# File lib/grape/axlsx/renderer.rb, line 21 def file File.join view_path, template_with_extension end
template_content()
click to toggle source
# File lib/grape/axlsx/renderer.rb, line 29 def template_content File.read(file) end
template_with_extension()
click to toggle source
# File lib/grape/axlsx/renderer.rb, line 25 def template_with_extension template[/\.axlsx$/] ? template : "#{template}.axlsx" end