Sha256: 1f795cf9e41ebcdc37948ebdadebca3fe968773fee06e3e28689b151e0eb66b0
Contents?: true
Size: 961 Bytes
Versions: 4
Compression:
Stored size: 961 Bytes
Contents
require 'haml' module Soca module Plugins class Haml < Soca::Plugin name 'haml' 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 private def haml_from options.has_key?(:from) ? File.join(app_dir, options[:from]) : File.join(app_dir, 'haml') end def haml_to options.has_key?(:to) ? File.join(app_dir, options[:to]) : File.join(app_dir, '') end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
soca-0.3.3 | lib/soca/plugins/haml.rb |
soca-0.3.2 | lib/soca/plugins/haml.rb |
soca-0.3.1 | lib/soca/plugins/haml.rb |
soca-0.3.0 | lib/soca/plugins/haml.rb |