Class: Netzke::Core::CssConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/netzke/core/css_config.rb

Overview

This class is responsible of assemblage of stylesheet dependencies. It is passed as block parameter to the client_styles DSL method:

class MyComponent < Netzke::Base
  client_styles do |c|
    c.require :extra_styles
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ CssConfig



14
15
16
17
# File 'lib/netzke/core/css_config.rb', line 14

def initialize(klass)
  @klass = klass
  @required_files = []
end

Instance Attribute Details

#required_filesObject

Returns the value of attribute required_files



12
13
14
# File 'lib/netzke/core/css_config.rb', line 12

def required_files
  @required_files
end

Instance Method Details

#require(*args) ⇒ Object

Use it to specify extra stylesheet files to be loaded for the component.

It may accept one or more symbols or strings.

Symbols will be expanded following a convention, e.g.:

class MyComponent < Netzke::Base
  client_styles do |c|
    c.require :some_styles
  end
end

This will “require” a stylesheet file {component_location}/my_component/client/some_styles.css

Strings will be interpreted as full paths to the required JavaScript file:

client_styles do |c|
  c.require "#{File.dirname(__FILE__)}/my_component/one.css", "#{File.dirname(__FILE__)}/my_component/two.css"
end


38
39
40
41
# File 'lib/netzke/core/css_config.rb', line 38

def require(*args)
  callr = caller.first
  @required_files |= args.map{ |a| a.is_a?(Symbol) ? expand_css_require_path(a, callr) : a }
end