Module: Roda::RodaPlugins::Assets::ClassMethods

Defined in:
lib/roda/plugins/assets.rb

Instance Method Summary collapse

Instance Method Details

#assets_optsObject

Return the assets options for this class.



386
387
388
# File 'lib/roda/plugins/assets.rb', line 386

def assets_opts
  opts[:assets]
end

#compile_assets(type = nil) ⇒ Object

Compile options for the given asset type. If no asset_type is given, compile both the :css and :js asset types. You can specify an array of types (e.g. [:css, :frontend]) to compile assets for the given asset group.



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/roda/plugins/assets.rb', line 394

def compile_assets(type=nil)
  require 'fileutils'

  unless assets_opts[:compiled]
    opts[:assets] = assets_opts.merge(:compiled => {})
  end

  if type == nil
    _compile_assets(:css)
    _compile_assets(:js)
  else
    _compile_assets(type)
  end

  if assets_opts[:precompiled]
    require 'json'
    ::FileUtils.mkdir_p(File.dirname(assets_opts[:precompiled]))
    ::File.open(assets_opts[:precompiled], 'wb'){|f| f.write(assets_opts[:compiled].to_json)}
  end

  assets_opts[:compiled]
end