Sha256: b6a70da611f9bf68d25ea6dc7d5ee0f1fc009a5a6b87a0bb73e61a2736e4464a
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
namespace :precompiled_haml do desc "Initial setup" task :install do end desc 'Cleanup' task :cleanup do end desc 'Precompile' task :precompile => :environment do precompiled_files = {} target_path = Rails.root.join('app/precompiled_views') ActionController::Base.view_paths.each do |path| path = path.to_s Dir[File.join(path, '**/*.haml')].each do |haml| haml.slice! path if precompiled_files[haml] puts "#{path} -> #{haml} already was precompiled" else precompiled_files[haml] = path precompiled_name = File.join target_path, haml.sub(/haml\z/, 'precompiled_haml') FileUtils.mkdir_p File.dirname precompiled_name File.open precompiled_name, 'w' do |f| # TODO. This precompiling must be more complicated (because it's type-dependent) tmpl = File.read(File.join path, haml) f.puts Haml::Engine.new(tmpl, Haml::Template.options.dup).compiler.precompiled end puts "#{precompiled_name} compiled!" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
precompiled_haml-0.0.1 | lib/precompiled_haml/tasks.rb |