Public Instance methods
assets_opts()
Return the assets options for this class.
[show source]
# File lib/roda/plugins/assets.rb 502 def assets_opts 503 opts[:assets] 504 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 510 def compile_assets(type=nil) 511 require 'fileutils' 512 513 unless assets_opts[:compiled] 514 opts[:assets] = assets_opts.merge(:compiled => _compiled_assets_initial_hash).freeze 515 end 516 517 if type == nil 518 _compile_assets(:css) 519 _compile_assets(:js) 520 else 521 _compile_assets(type) 522 end 523 524 if precompile_file = assets_opts[:precompiled] 525 require 'json' 526 ::FileUtils.mkdir_p(File.dirname(precompile_file)) 527 tmp_file = "#{precompile_file}.tmp" 528 ::File.open(tmp_file, 'wb'){|f| f.write((opts[:json_serializer] || :to_json.to_proc).call(assets_opts[:compiled]))} 529 ::File.rename(tmp_file, precompile_file) 530 end 531 532 assets_opts[:compiled] 533 end