Class: Quarto::Rendering
- Inherits:
-
Object
- Object
- Quarto::Rendering
- Defined in:
- lib/quarto/rendering.rb
Overview
:nodoc: all
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(__erb_template, __locals, __mixins) ⇒ Rendering
constructor
A new instance of Rendering.
Constructor Details
#initialize(__erb_template, __locals, __mixins) ⇒ Rendering
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/quarto/rendering.rb', line 3 def initialize(__erb_template, __locals, __mixins) unless __erb_template.is_a?(ERB) raise ArgumentError, "Expected ERB but got #{__erb_template.inspect}" end unless __locals.is_a?(Hash) raise ArgumentError, "Expected Hash but got #{__locals.inspect}" end unless __mixins.is_a?(Array) raise ArgumentError, "Expected Array but got #{__mixins.inspect}" end __mixins.each do |mixin| unless mixin.is_a?(Module) raise ArgumentError, "Expected Module but got #{mixin.inspect}" end extend(mixin) end __b = binding __locals.each_key do |var_name| # In the context of the binding (rather than of this block), # define the local variables eval "#{var_name} = __locals[:#{var_name}]", __b end @result = __erb_template.result(__b) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
38 39 40 |
# File 'lib/quarto/rendering.rb', line 38 def result @result end |
Class Method Details
.render(erb_template, locals, mixins = [], &block) ⇒ Object
34 35 36 |
# File 'lib/quarto/rendering.rb', line 34 def self.render(erb_template, locals, mixins = [], &block) new(erb_template, locals, mixins, &block).result end |