Module: Sinatra::DynamicMatic

Defined in:
lib/sinatra/dynamicmatic.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sinatra/dynamicmatic.rb', line 6

def self.registered(app)
  app.set :lock, true
  app.set :public, Proc.new {app.root && File.join(app.root, 'site')}

  configuration = StaticMatic::Configuration.new

  config_file = "#{app.root}/src/configuration.rb"

  if File.exists?(config_file)
    config = File.read(config_file)
    eval(config)
  end

  staticmatic = StaticMatic::Base.new(app.root, configuration)
  app.set :_staticmatic, staticmatic

  Dir[File.join(app._staticmatic.src_dir, "layouts", "*.haml")].each do |layout|
    name = layout[/([^\/]*)\.haml$/, 1].to_sym
    haml = File.read(layout)
    app.template(name) {haml}
    app.layout {haml} if name == :application
  end

  before do
    @staticmatic = staticmatic
    staticmatic.instance_variable_set('@current_page', request.path_info)
  end
end

Instance Method Details

#staticmaticObject



35
36
37
# File 'lib/sinatra/dynamicmatic.rb', line 35

def staticmatic
  _staticmatic
end