Class: Soca::Plugins::Haml
- Inherits:
-
Soca::Plugin
- Object
- Soca::Plugin
- Soca::Plugins::Haml
- Defined in:
- lib/soca/plugins/haml.rb
Instance Attribute Summary
Attributes inherited from Soca::Plugin
Instance Method Summary collapse
Methods inherited from Soca::Plugin
#app_dir, #config, #initialize, #logger, name, plugins
Constructor Details
This class inherits a constructor from Soca::Plugin
Instance Method Details
#before_build ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/soca/plugins/haml.rb', line 9 def before_build Dir[File.join(haml_from, "**/*.haml")].each do |file| Soca.logger.debug "Running #{file} through Haml." basename = File.basename(file, ".haml") dir = File.dirname(file).sub(/^#{haml_from}/, haml_to) new_file = basename + ".html" FileUtils.mkdir_p(dir) unless File.exists?(dir) File.open(File.join(dir, new_file), 'w') do |f| f << ::Haml::Engine.new(File.read(file)).render end Soca.logger.debug "Wrote to #{File.join(dir, new_file)}" end end |