From 092f7510b40c2d59bae16ae09f1803e4b9715633 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 12 May 2014 15:53:22 -0400 Subject: [PATCH] Plugin Backwards compatibility layer for ES6 --- .../tilt/es6_module_transpiler_template.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb index 5c65562d360..2b2086226f8 100644 --- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb @@ -64,6 +64,15 @@ module Tilt klass.protect do @output = klass.v8.eval(generate_source(scope)) end + + # 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 scope.logical_path =~ /discourse\/controllers\/(.*)/ + class_name = Regexp.last_match[1].gsub(/[\-\/]/, '_').classify + @output << "\n\nDiscourse.#{class_name}Controller = require('#{scope.logical_path}').default" + end + @output end