Sha256: 20762c2f61bc537aa7ff2226ce388d1a3da34094bd59e1321e416ad1d4572230
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
# export to all templates # = asset 'www/index.scss' # = asset 'www/index.coffee' module DefaultHelper def asset_include path raise ArgumentError.new("Path can't be empty") if path.empty? url = if path.starts_with?('/') || path.include?('//') path else '/compiled_asset/%s' % path end ext = url.split('?').first.split('.').last if ['coffee', 'js'].include?(ext) %[<script src="#{url}"></script>] else %[<link rel="stylesheet" href="#{url}" />] end end # builds full asset path based on resource extension # asset('main/index.coffee') # will render 'app/assets/main/index.coffee' as http://aset.path/assets/main-index-md5hash.js def asset file, dev_file=nil # return second link if it is defined and we are in dev mode return asset_include dev_file if dev_file && Lux.dev? # return internet links return asset_include file if file.starts_with?('/') || file.starts_with?('http') # return asset link in production or faile unless able unless Lux.config(:compile_assets) mfile = MiniAsset.manifest['files'][file] raise 'Compiled asset link for "%s" not found in manifest.json' % file if mfile.empty? return asset_include Lux.config.assets_root.to_s + mfile end # try to create list of incuded files and show every one of them data = [] asset = MiniAsset.create file for file in asset.files data.push asset_include file end data.join($/) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lux-fw-0.1.17 | ./lib/plugins/assets/helper_module_adapter.rb |