Sha256: c01c764eefc43f838e8d70ffc2e0ae4fac7da49f3c8eb48bd4d704228a5d9703
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# encoding: utf-8 require 'active_support/json/encoding' module UeditorRails module Util class << self ASSET_FORMAT = '*.{coffee,scss,sass,png,jpeg,jpg,gif,js,css,erb,swf}' NEED_TO_COMPILE_STYLESHEET_EXT = %w(.scss .sass .coffee .erb) def js_replace(dom_id, options = nil) js_options = (options && !options.keys.empty?)? ActiveSupport::JSON.encode(options) : '{}' js = <<-JS if(window.UEDITOR_FIELDS === undefined) { window.UEDITOR_FIELDS = []; } window.UEDITOR_FIELDS.push({id: '#{dom_id}', opt: #{js_options}}) JS js.html_safe end def precompile_assets assets = [] %w(app vendor).each do |source| %w(images javascripts stylesheets).each do |kind| Dir[UeditorRails.root_path.join("#{source}/assets/#{kind}/**", ASSET_FORMAT)].each do |path| next if File.basename(path)[0] == '_' ext = File.extname(path) path = path[0..-ext.length-1] if NEED_TO_COMPILE_STYLESHEET_EXT.include? ext assets << Pathname.new(path).relative_path_from(UeditorRails.root_path.join("#{source}/assets/#{kind}")) end end end assets end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ueditor_rails-0.0.2 | lib/ueditor_rails/util.rb |