Method: HtmlTemplate#render

Defined in:
lib/html/template.rb

#render(**kwargs) ⇒ Object

class Template::Context



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/html/template.rb', line 403

def render( **kwargs )
  ## todo: use locals / assigns or something instead of **kwargs - why? why not?

  ##        allow/support (extra) locals / assigns - why? why not?

    ## note: Ruby >= 2.5 has ERB#result_with_hash - use later - why? why not?


  kwargs = kwargs.reduce( {} ) do |hash, (key, val)|
                                 ## puts "#{key} => #{val}:#{val.class.name}"

                                 hash[key] = to_recursive_ostruct( val )
                                 hash
                               end

  ## (auto-)convert array and hash values to ostruct

  ##   for easy dot (.) access

  ##      e.g. student.name instead of student[:name]


  @template.result( Context.new( **kwargs ).get_binding )
end