mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
ES6: Mega update of controllers
This commit is contained in:
@ -70,7 +70,7 @@ module Tilt
|
||||
# For backwards compatibility with plugins, for now export the Global format too.
|
||||
# We should eventually have an upgrade system for plugins to use ES6 or some other
|
||||
# resolve based API.
|
||||
if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes)\/(.*)/
|
||||
if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes|mixins)\/(.*)/
|
||||
type = Regexp.last_match[2]
|
||||
file_name = Regexp.last_match[3].gsub(/[\-\/]/, '_')
|
||||
class_name = file_name.classify
|
||||
@ -82,7 +82,13 @@ module Tilt
|
||||
require_name = module_name(scope.root_path, scope.logical_path)
|
||||
|
||||
if require_name !~ /\-test$/
|
||||
@output << "\n\nDiscourse.#{class_name}#{type.classify} = require('#{require_name}').default;\n"
|
||||
result = "#{class_name}#{type.classify}"
|
||||
|
||||
# HAX
|
||||
result = "Controller" if result == "ControllerController"
|
||||
result.gsub!(/Mixin$/, '')
|
||||
|
||||
@output << "\n\nDiscourse.#{result} = require('#{require_name}').default;\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user