Class: Conjoin::Assets::App

Inherits:
Cuba
  • Object
show all
Defined in:
lib/conjoin/assets.rb

Overview

scss.render

Instance Method Summary collapse

Methods inherited from Cuba

initialize!, root, root=, settings=

Instance Method Details

#add_asset(file, ext) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/conjoin/assets.rb', line 170

def add_asset file, ext
  dir     = ''
  new_ext = false

  case file
  when /^bower/
    dir = 'assets/'
  when /^widgets/
    dir = '/'
  else
    case ext
    when 'js'
      dir = 'assets/javascripts/'
    when 'css'
      dir = 'assets/stylesheets/'
    else
      dir = 'assets/'
    end
  end

  case ext
  when 'css'
    %w(scss styl).each do |type|
      new_ext = type if stylesheet_assets.include? file + ".#{type}"
    end
  when 'js'
    new_ext = 'coffee' if javascript_assets.include? file + '.coffee' \
                       or javascript_head_assets.include? file + '.coffee'
  end

  if new_ext
    render "#{Assets.app.root}/app/#{dir}#{file}.#{new_ext}"
  else
    File.read "#{Assets.app.root}/app/#{dir}#{file}.#{ext}"
  end
end