Sha256: 5850132c07e3247bd594aabc0c9d1804ea4a1f622af7aa113674cf863bdf6f71

Contents?: true

Size: 944 Bytes

Versions: 1

Compression:

Stored size: 944 Bytes

Contents

require "actionview_precompiler/version"
require "actionview_precompiler/template_parser"
require "actionview_precompiler/render_parser"
require "actionview_precompiler/precompiler"
require "actionview_precompiler/parsed_filename"

module ActionviewPrecompiler
  class Error < StandardError; end

  def self.precompile(verbose: false)
    target = ActionController::Base # fixme
    view_paths = target.view_paths
    lookup_context = ActionView::LookupContext.new(view_paths)
    paths = view_paths.map(&:path)
    precompiler = Precompiler.new(paths)

    mod = target.view_context_class
    count = 0
    precompiler.each_lookup_args do |args|
      templates = lookup_context.find_all(*args)
      templates.each do |template|
        puts "precompiling: #{template.inspect}" if verbose
        count += 1
        template.send(:compile!, mod)
      end
    end

    if verbose
      puts "Precompiled #{count} Templates"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actionview_precompiler-0.1.0 lib/actionview_precompiler.rb