Class: Mint::Style
Instance Attribute Summary
Attributes inherited from Resource
#context, #destination, #name, #root, #source, #type
Instance Method Summary collapse
-
#initialize(source, root: nil, destination: nil, context: nil, name: nil, &block) ⇒ Style
constructor
Creates a new Style object using a mandatory source file and optional configuration options.
-
#render ⇒ String
Renders a Style object through Tilt template system.
-
#rendered? ⇒ Boolean
Determines whether a Style object is supposed to be rendered.
Methods inherited from Resource
#destination_directory, #destination_directory_path, #destination_file, #destination_file_path, #equal?, #publish!, #renderer=, #root_directory, #root_directory_path, #source_directory, #source_directory_path, #source_file, #source_file_path
Constructor Details
#initialize(source, root: nil, destination: nil, context: nil, name: nil, &block) ⇒ Style
Creates a new Style object using a mandatory source file and optional configuration options.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mint/style.rb', line 9 def initialize(source, root: nil, destination: nil, context: nil, name: nil, &block) super(source, root: root, destination: destination, context: context, name: name, &block) self.type = :style # We want to render final stylesheet to the /css subdirectory if # an output directory is not specified and we are dealing with # a named template (not a local file). If we don't do this, the rendered # CSS file might be picked up next time we look for a named template # in this directory, and the (correct) SASS file won't be picked up. # However, if a destination directory is already specified, we # leave it alone. if Mint.template?(self.source_directory) and rendered? tmp_dir = Mint.path_for_scope(:user) + "tmp" self.destination ||= tmp_dir.to_s self.root = "/" end end |
Instance Method Details
#render ⇒ String
Renders a Style object through Tilt template system
37 38 39 |
# File 'lib/mint/style.rb', line 37 def render super end |
#rendered? ⇒ Boolean
Determines whether a Style object is supposed to be rendered.
30 31 32 |
# File 'lib/mint/style.rb', line 30 def rendered? true # All styles need rendering now (CSS for imports, Sass for compilation) end |