Sha256: 02d0866d9013254e0d8b519b0d3aeab65da0c607412acdb05eeea747f80ade53

Contents?: true

Size: 988 Bytes

Versions: 4

Compression:

Stored size: 988 Bytes

Contents

require "actionview_precompiler/version"
require "actionview_precompiler/ast_parser"
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

4 entries across 4 versions & 1 rubygems

Version Path
actionview_precompiler-0.2.3 lib/actionview_precompiler.rb
actionview_precompiler-0.2.2 lib/actionview_precompiler.rb
actionview_precompiler-0.2.1 lib/actionview_precompiler.rb
actionview_precompiler-0.2.0 lib/actionview_precompiler.rb