Module: Roda::RodaPlugins::Assets::ClassMethods
- Defined in:
- lib/roda/plugins/assets.rb
Instance Method Summary collapse
-
#assets_opts ⇒ Object
Return the assets options for this class.
-
#compile_assets(type = nil) ⇒ Object
Compile options for the given asset type.
Instance Method Details
#assets_opts ⇒ Object
Return the assets options for this class.
429 430 431 |
# File 'lib/roda/plugins/assets.rb', line 429 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.
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/roda/plugins/assets.rb', line 437 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((opts[:json_serializer] || :to_json.to_proc).call(assets_opts[:compiled]))} end assets_opts[:compiled] end |