Class: Lrama::ERB
- Inherits:
-
Object
- Object
- Lrama::ERB
- Defined in:
- lib/lrama/erb.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file) ⇒ ERB
constructor
A new instance of ERB.
- #render(**kwargs) ⇒ Object
Constructor Details
#initialize(file) ⇒ ERB
Returns a new instance of ERB.
14 15 16 17 18 19 20 21 22 |
# File 'lib/lrama/erb.rb', line 14 def initialize(file) input = File.read(file) if ::ERB.instance_method(:initialize).parameters.last.first == :key @erb = ::ERB.new(input, trim_mode: '-') else @erb = ::ERB.new(input, nil, '-') # steep:ignore UnexpectedPositionalArgument end @erb.filename = file end |
Class Method Details
.render(file, **kwargs) ⇒ Object
9 10 11 |
# File 'lib/lrama/erb.rb', line 9 def self.render(file, **kwargs) new(file).render(**kwargs) end |
Instance Method Details
#render(**kwargs) ⇒ Object
25 26 27 |
# File 'lib/lrama/erb.rb', line 25 def render(**kwargs) @erb.result_with_hash(kwargs) end |