Module: UeditorRails::Util
- Defined in:
- lib/ueditor_rails/util.rb
Constant Summary collapse
- ASSET_FORMAT =
'*.{coffee,scss,sass,png,jpeg,jpg,gif,js,css,erb,swf,exe}'- NEED_TO_COMPILE_STYLESHEET_EXT =
%w(.scss .sass .coffee .erb)
Class Method Summary collapse
Class Method Details
.js_replace(dom_id, options = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ueditor_rails/util.rb', line 10 def js_replace(dom_id, = nil) = ( && !.keys.empty?)? ActiveSupport::JSON.encode() : '{}' js = " if(window.UEDITOR_FIELDS === undefined) {\n window.UEDITOR_FIELDS = [];\n }\n window.UEDITOR_FIELDS.push({id: '\#{dom_id}', opt: \#{js_options}})\n JS\n js.html_safe\nend\n" |
.precompile_assets ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ueditor_rails/util.rb', line 21 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 |