Class: Soca::Plugins::Haml

Inherits:
Soca::Plugin show all
Defined in:
lib/soca/plugins/haml.rb

Instance Attribute Summary

Attributes inherited from Soca::Plugin

#options, #pusher

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_buildObject



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