Sha256: 712b6a96fba2ddf8d75350529ba40e09b6bcc9c8cc594054148b328a893e5286

Contents?: true

Size: 1.12 KB

Versions: 35

Compression:

Stored size: 1.12 KB

Contents

module CurrentThemeHelper
  def current_theme_object
    @current_theme_object ||= "BulletTrain::Themes::#{current_theme.to_s.classify}::Theme".constantize.new
  end

  def render(options = {}, locals = {}, &block)
    options = current_theme_object.resolved_partial_path_for(@lookup_context, options, locals) || options

    # This is where we try to just lean on Rails default behavior. If someone renders `shared/box` and also has a
    # `app/views/shared/_box.html.erb`, then no error will be thrown and we will have never interfered in the normal
    # Rails behavior.
    #
    # We also don't do anything special if someone renders `shared/box` and we've already previously resolved that
    # partial to be served from `themes/light/box`. In that case, we've already replaced `shared/box` with the
    # actual path of the partial, and Rails will do the right thing from this point.
    #
    # However, if one of those two situations isn't true, then this call here will throw an exception and we can
    # perform the appropriate magic to figure out where amongst the themes the partial should be rendering from.
    super
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
bullet_train-themes-1.10.0 app/helpers/current_theme_helper.rb
bullet_train-themes-1.9.0 app/helpers/current_theme_helper.rb
bullet_train-themes-1.8.5 app/helpers/current_theme_helper.rb
bullet_train-themes-1.8.4 app/helpers/current_theme_helper.rb
bullet_train-themes-1.8.3 app/helpers/current_theme_helper.rb
bullet_train-themes-1.8.2 app/helpers/current_theme_helper.rb
bullet_train-themes-1.8.1 app/helpers/current_theme_helper.rb
bullet_train-themes-1.8.0 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.23 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.22 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.21 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.20 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.19 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.18 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.17 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.16 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.15 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.14 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.13 app/helpers/current_theme_helper.rb
bullet_train-themes-1.7.12 app/helpers/current_theme_helper.rb