Class: BulletTrain::Themes::Base::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/bullet_train/themes.rb

Instance Method Summary collapse

Instance Method Details

#directory_orderObject



31
32
33
# File 'lib/bullet_train/themes.rb', line 31

def directory_order
  ["base"]
end

#resolved_partial_path_for(lookup_context, path, locals) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bullet_train/themes.rb', line 35

def resolved_partial_path_for(lookup_context, path, locals)
  # We disable partial path caching in development so new templates are taken into account without restarting the server.
  partial_paths = {}

  BulletTrain::Themes.partial_paths.fetch(path) do
    if (theme_path = BulletTrain::Themes.theme_invocation_path_for(path))
      # TODO directory_order should probably come from the `Current` model.
      if (partial = lookup_context.find_all(theme_path, directory_order.map { "themes/#{_1}" }, true, locals.keys).first)
        resolved_partial = partial.virtual_path.gsub("/_", "/")
        if Rails.env.development?
          partial_paths[path] = resolved_partial
        else
          BulletTrain::Themes.partial_paths[path] = resolved_partial
        end
      end
    end
  end
end