Class: RFPDF::View
- Inherits:
-
Object
- Object
- RFPDF::View
- Defined in:
- vendor/plugins/rfpdf/lib/rfpdf/view.rb
Constant Summary
- @@backward_compatibility_mode =
false
Class Method Summary
Instance Method Summary
- - (Boolean) compilable?
-
- (View) initialize(action_view)
constructor
A new instance of View.
- - (Object) render(template, local_assigns = {})
Constructor Details
- (View) initialize(action_view)
A new instance of View
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'vendor/plugins/rfpdf/lib/rfpdf/view.rb', line 36 def initialize(action_view) @action_view = action_view # Override with @options_for_rfpdf Hash in your controller = { # Run through latex first? (for table of contents, etc) :pre_process => false, # Debugging mode; raises exception :debug => false, # Filename of pdf to generate :file_name => "#{@action_view.controller.action_name}.pdf", # Temporary Directory :temp_dir => "#{File.expand_path(RAILS_ROOT)}/tmp" }.merge(@action_view.controller.instance_eval{ } || {}).with_indifferent_access end |
Class Method Details
+ (Boolean) compilable?
51 52 53 |
# File 'vendor/plugins/rfpdf/lib/rfpdf/view.rb', line 51 def self.compilable? false end |
Instance Method Details
- (Boolean) compilable?
55 56 57 |
# File 'vendor/plugins/rfpdf/lib/rfpdf/view.rb', line 55 def compilable? self.class.compilable? end |
- (Object) render(template, local_assigns = {})
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'vendor/plugins/rfpdf/lib/rfpdf/view.rb', line 59 def render(template, local_assigns = {}) @pdf_name = "Default.pdf" if @pdf_name.nil? unless @action_view.controller.headers["Content-Type"] == 'application/pdf' @generate = true @action_view.controller.headers["Content-Type"] = 'application/pdf' @action_view.controller.headers["Content-disposition:"] = "inline; filename=\"#{@options[:file_name]}\"" end assigns = @action_view.assigns.dup if content_for_layout = @action_view.instance_variable_get("@content_for_layout") assigns['content_for_layout'] = content_for_layout end result = @action_view.instance_eval do assigns.each do |key,val| instance_variable_set "@#{key}", val end local_assigns.each do |key,val| class << self; self; end.send(:define_method,key){ val } end ERB.new(@@backward_compatibility_mode == true ? template : template.source).result(binding) end end |