Sha256: 0b162feea77b7c4e42b41d1d6b735570685f5160bbdfe29aa45ff50a1fe506d7

Contents?: true

Size: 1.11 KB

Versions: 27

Compression:

Stored size: 1.11 KB

Contents

module Deface
  class Precompiler

    extend Deface::TemplateHelper

    def self.precompile
      base_path = Rails.root.join("app/compiled_views")
      # temporarily configures deface env and loads
      # all overrides so we can precompile
      unless Rails.application.config.deface.enabled
        Rails.application.config.deface = Deface::Environment.new
        Rails.application.config.deface.overrides.early_check
        Rails.application.config.deface.overrides.load_all Rails.application
      end

      Rails.application.config.deface.overrides.all.each do |virtual_path,overrides|
        template_path = base_path.join( "#{virtual_path}.html.erb")

        FileUtils.mkdir_p template_path.dirname
        begin
          source = load_template_source(virtual_path.to_s, false, true)
          if source.blank?
            raise "Compiled source was blank for '#{virtual_path}'"
          end
          File.open(template_path, 'w') {|f| f.write source } 
        rescue Exception => e
          puts "Unable to precompile '#{virtual_path}' due to: "
          puts e.message
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
deface-1.9.0 lib/deface/precompiler.rb
deface-1.8.2 lib/deface/precompiler.rb
deface-1.8.1 lib/deface/precompiler.rb
deface-1.8.0 lib/deface/precompiler.rb
deface-1.7.0 lib/deface/precompiler.rb
deface-1.6.2 lib/deface/precompiler.rb
deface-1.6.1 lib/deface/precompiler.rb
deface-1.6.0 lib/deface/precompiler.rb
deface-1.5.3 lib/deface/precompiler.rb
deface-1.5.2 lib/deface/precompiler.rb
deface-1.5.1 lib/deface/precompiler.rb
deface-1.5.0 lib/deface/precompiler.rb
deface-1.4.0 lib/deface/precompiler.rb
deface-1.3.2 lib/deface/precompiler.rb
deface-1.3.1 lib/deface/precompiler.rb
deface-1.3.0 lib/deface/precompiler.rb
deface-1.2.0 lib/deface/precompiler.rb
deface-1.1.0 lib/deface/precompiler.rb
deface-1.0.2 lib/deface/precompiler.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/deface-1.0.1/lib/deface/precompiler.rb