Module: BravuraTemplateBase

Defined in:
lib/bravura_template_base.rb,
lib/bravura_template_base/engine.rb,
lib/bravura_template_base/version.rb,
app/jobs/bravura_template_base/application_job.rb,
app/models/bravura_template_base/application_record.rb,
app/helpers/bravura_template_base/application_helper.rb,
app/mailers/bravura_template_base/application_mailer.rb,
app/controllers/bravura_template_base/application_controller.rb

Defined Under Namespace

Modules: ApplicationHelper Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Engine

Constant Summary collapse

AVAILABLE_TEMPLATES =
[ "bravura_template_normal", "bravura_template_product_updates" ]
DEFAULT_TEMPLATE =
"bravura_template_normal"
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.load_template(app, account) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bravura_template_base.rb', line 5

def self.load_template(app, )
  raise ArgumentError, "account must respond to :settings and :id" unless .respond_to?(:settings) && .respond_to?(:id)

  template_name = .settings.design.blog_template_gem

  begin
    engine_class = "#{template_name.camelize}::Engine".constantize
    app.config.assets.paths << engine_class.root.join("app/javascript")
    app.config.assets.precompile << "#{template_name}/application.css"
  rescue NameError => e
    logger.warn "Template #{template_name} not found for account #{.id}, falling back to default"
    if template_name != DEFAULT_TEMPLATE
      .settings.design.blog_template_gem = DEFAULT_TEMPLATE
      load_template(app, )
    else
      raise "Default template #{DEFAULT_TEMPLATE} not found: #{e.message}"
    end
  end
end

.loggerObject



25
26
27
# File 'lib/bravura_template_base.rb', line 25

def self.logger
  Rails.logger || Logger.new(STDOUT)
end