Class: Luoma::HashLoader
- Inherits:
-
TemplateLoader
- Object
- TemplateLoader
- Luoma::HashLoader
- Defined in:
- lib/luoma/loader.rb,
sig/luoma/loader.rbs
Overview
A template loader that reads templates from a hash.
Instance Method Summary collapse
- #get_source(env, name, context: nil, **kwargs) ⇒ Object
-
#initialize(templates) ⇒ HashLoader
constructor
A new instance of HashLoader.
Methods inherited from TemplateLoader
Constructor Details
#initialize(templates) ⇒ HashLoader
Returns a new instance of HashLoader.
38 39 40 41 |
# File 'lib/luoma/loader.rb', line 38 def initialize(templates) super() @templates = templates end |
Instance Method Details
#get_source(env, name, context: nil, **kwargs) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/luoma/loader.rb', line 43 def get_source(env, name, context: nil, **kwargs) source = @templates[name] raise TemplateNotFoundError.new("template not found #{name}") unless source TemplateSource.new(source: source, name: name) end |