Sha256: 9999de3e53991d50b71dc8a71164b8115cfc579cabfa8af0945808bee4afede4
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 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,exe}' 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
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
ueditor_rails4-0.0.5 | lib/ueditor_rails/util.rb |
ueditor_rails-0.0.4 | lib/ueditor_rails/util.rb |