Sha256: 24fe1835fbe689daa14b595401888b7bb0ae4dc04bf7b5fb2bda998d2b2bcdb7

Contents?: true

Size: 794 Bytes

Versions: 4

Compression:

Stored size: 794 Bytes

Contents

require 'rack'

class Susanoo::Application

  # This controller is responsible for serving/building index.html file.
  class Index < Susanoo::Controller
    def call(env)
      # Tilt template object
      template = Tilt.new(File.join(project_root, 'src/index.html.erb'))
      [200, {'Content-Type' => 'text/html'}, [template.render(self)]]
    end

    def build(generator)
      # Configure Sprockets::Helpers (if necessary)
      Sprockets::Helpers.configure do |config|
        config.environment = @environment
        config.prefix      = 'assets'
      end

      template = Tilt.new(File.join(project_root, 'src/index.html.erb'))
      data = template.render(self)
      # God forgive me for hard coding this part
      generator.create_file 'www/index.html', data
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
susanoo-0.8.0 lib/susanoo/controllers/index.rb
susanoo-0.7.4 lib/susanoo/controllers/index.rb
susanoo-0.7.2 lib/susanoo/controllers/index.rb
susanoo-0.7.1 lib/susanoo/controllers/index.rb