module Roda::RodaPlugins::Assets::ClassMethods

  1. lib/roda/plugins/assets.rb

Methods

Public Instance

  1. compile_assets

Public Instance methods

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
508 def compile_assets(type=nil)
509   require 'fileutils'
510 
511   unless assets_opts[:compiled]
512     opts[:assets] = assets_opts.merge(:compiled => _compiled_assets_initial_hash).freeze
513   end
514 
515   if type == nil
516     _compile_assets(:css)
517     _compile_assets(:js)
518   else
519     _compile_assets(type)
520   end
521 
522   if precompile_file = assets_opts[:precompiled]
523     ::FileUtils.mkdir_p(File.dirname(precompile_file))
524     tmp_file = "#{precompile_file}.tmp"
525     ::File.open(tmp_file, 'wb'){|f| f.write(json_serializer.call(assets_opts[:compiled]))}
526     ::File.rename(tmp_file, precompile_file)
527   end
528 
529   assets_opts[:compiled]
530 end