Module: Mixin::Generators::TemplateLoader
- Extended by:
- TemplateLoader
- Included in:
- TemplateLoader
- Defined in:
- lib/fox/interface/thor/mixin/generators/template_loader.rb
Constant Summary collapse
- TEMPLATE_DIR =
default template directory
'template'
Instance Method Summary collapse
-
#load(language) ⇒ String
Result template source.
-
#templates ⇒ Array<String>
List of all templates.
Instance Method Details
#load(language) ⇒ String
Returns Result template source.
25 26 27 28 29 30 31 |
# File 'lib/fox/interface/thor/mixin/generators/template_loader.rb', line 25 def load language file = templates.find { |file| File.basename(file).start_with?(language) } raise Fox::LoadTemplateError.new("Template for #{language} not found") if file.nil? File.read(file) end |
#templates ⇒ Array<String>
Returns List of all templates.
39 40 41 42 |
# File 'lib/fox/interface/thor/mixin/generators/template_loader.rb', line 39 def templates path = File.( File.dirname( __FILE__ ) + '../../../../../') Dir["#{path}/#{TEMPLATE_DIR}/*_template.erb"] end |