Module: Generambo::Helpers::TemplateHandler
- Defined in:
- lib/generambo/helpers/template_handler.rb
Class Method Summary collapse
Class Method Details
.handle!(path, properties) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generambo/helpers/template_handler.rb', line 6 def handle!(path, properties) files = Dir["#{path}/**/*"] files.each do |file| next if File.directory?(file) file_source = IO.read(file) template = Liquid::Template.parse(file_source) output = template.render(properties) # delete template file File.delete(file) # remove .liquid extension file.slice! File.extname(file) # write handled file File.open(file, 'w+') { |f| f.write(output) } end end |