mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 23:48:34 +08:00
256d7a00e9
* Update sass-rails. * FIX: Tilt dependency has been removed from Ember::Handlebars::Template. * Update `DiscourseIIFE` to new Sprockets API. * `Rails.application.assets` returns `nil` in production. * Move sprockets-rails out of the assets group. * Pin ember-rails to 0.18.5 which works with Sprockets 3.x. * Update sprockets to 3.6.0. * Make `DiscourseSassCompiler` work with Sprockets 3. * Use `Sass::Rails::SassImporterGlobbing` instead of haxxing our own. * Moneky patch so that we don't add dependencies for our custom css. * FIX: Missing class. * Upgrade ember-handlebars-template. * FIX: require path needs to share the same root as the folder's path. * Bump discourse-qunit-rails. * Update ember-template-compiler.js to 1.12.2. * `prepend` is private in Ruby 2.0.0.
41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
class DiscourseIIFE
|
|
def initialize(options = {}, &block)
|
|
end
|
|
|
|
def self.instance
|
|
@instance ||= new
|
|
end
|
|
|
|
def self.call(input)
|
|
instance.call(input)
|
|
end
|
|
|
|
# Add a IIFE around our javascript
|
|
def call(input)
|
|
path = input[:environment].context_class.new(input).pathname.to_s
|
|
data = input[:data]
|
|
|
|
# Only discourse or admin paths
|
|
return data unless (path =~ /\/javascripts\/discourse/ || path =~ /\/javascripts\/admin/ || path =~ /\/test\/javascripts/)
|
|
|
|
# Ignore the js helpers
|
|
return data if (path =~ /test\_helper\.js/)
|
|
return data if (path =~ /javascripts\/helpers\//)
|
|
|
|
# Ignore ES6 files
|
|
return data if (path =~ /\.es6/)
|
|
|
|
# Ignore translations
|
|
return data if (path =~ /\/translations/)
|
|
|
|
# We don't add IIFEs to handlebars
|
|
return data if path =~ /\.handlebars/
|
|
return data if path =~ /\.shbrs/
|
|
return data if path =~ /\.hbrs/
|
|
return data if path =~ /\.hbs/
|
|
|
|
"(function () {\n\nvar $ = window.jQuery;\n// IIFE Wrapped Content Begins:\n\n#{data}\n\n// IIFE Wrapped Content Ends\n\n })(this);"
|
|
end
|
|
|
|
end
|