Class: Grape::Axlsx::Renderer
- Inherits:
-
Object
- Object
- Grape::Axlsx::Renderer
- Defined in:
- lib/grape/axlsx/renderer.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#view_path ⇒ Object
readonly
Returns the value of attribute view_path.
Instance Method Summary collapse
-
#initialize(view_path, template) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(scope) ⇒ Object
Constructor Details
#initialize(view_path, template) ⇒ Renderer
Returns a new instance of Renderer.
6 7 8 |
# File 'lib/grape/axlsx/renderer.rb', line 6 def initialize(view_path, template) @view_path, @template = view_path, template end |
Instance Attribute Details
#template ⇒ Object (readonly)
Returns the value of attribute template.
4 5 6 |
# File 'lib/grape/axlsx/renderer.rb', line 4 def template @template end |
#view_path ⇒ Object (readonly)
Returns the value of attribute view_path.
4 5 6 |
# File 'lib/grape/axlsx/renderer.rb', line 4 def view_path @view_path end |
Instance Method Details
#render(scope) ⇒ Object
10 11 12 13 14 15 16 17 |
# 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 |