module Roda::RodaPlugins::Assets::ClassMethods

  1. lib/roda/plugins/assets.rb

Methods

Public Instance

  1. assets_opts
  2. compile_assets

Public Instance methods

assets_opts()

Return the assets options for this class.

[show source]
    # File lib/roda/plugins/assets.rb
462 def assets_opts
463   opts[:assets]
464 end
compile_assets(type=nil)

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.

[show source]
    # File lib/roda/plugins/assets.rb
470 def compile_assets(type=nil)
471   require 'fileutils'
472 
473   unless assets_opts[:compiled]
474     opts[:assets] = assets_opts.merge(:compiled => _compiled_assets_initial_hash).freeze
475   end
476 
477   if type == nil
478     _compile_assets(:css)
479     _compile_assets(:js)
480   else
481     _compile_assets(type)
482   end
483 
484   if precompile_file = assets_opts[:precompiled]
485     require 'json'
486     ::FileUtils.mkdir_p(File.dirname(precompile_file))
487     tmp_file = "#{precompile_file}.tmp"
488     ::File.open(tmp_file, 'wb'){|f| f.write((opts[:json_serializer] || :to_json.to_proc).call(assets_opts[:compiled]))}
489     ::File.rename(tmp_file, precompile_file)
490   end
491 
492   assets_opts[:compiled]
493 end