Class: Roll::Amp::Style::Stylesheet

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::OutputSafetyHelper
Defined in:
lib/roll/amp/style/stylesheet.rb

Overview

The AMP stylesheet which can be loaded from file or assets pipeline and injected into HTML body.

Instance Method Summary collapse

Constructor Details

#initialize(app_path, assets, stylesheet_name) ⇒ Stylesheet

Initializes new instance of the AML stylesheet.

Parameters:

  • app_path (String)

    the Rails application root path.

  • assets (Sprockets::Environment)

    the Rails.application.assets

  • stylesheet_name (String)

    the stylesheet file name.



15
16
17
18
19
# File 'lib/roll/amp/style/stylesheet.rb', line 15

def initialize(app_path, assets, stylesheet_name)
  @app_path = app_path
  @assets = assets
  @stylesheet_name = stylesheet_name
end

Instance Method Details

#readString

Reads stylesheet content from file or assets pipeline. Usually the pipeline is used in dev/test mode, while on production the stylesheet would be read from file. string if content couldn’t be retreived.

Returns:

  • (String)

    CSS content as HTML-safe unescaped string or empty



26
27
28
# File 'lib/roll/amp/style/stylesheet.rb', line 26

def read
  raw(stylesheet_content)
end