ES6: Mega update of controllers

This commit is contained in:
Robin Ward
2014-08-12 19:04:36 -04:00
parent 1c9ccc6eb1
commit 0adfeb1cff
66 changed files with 239 additions and 344 deletions

View File

@ -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