From 5bbe938e829519a3f1ade228302aab4d3a6c9160 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 20 May 2014 11:13:43 -0400 Subject: [PATCH] FIX: Backwards compatibility layer was not handling constants that ended with 's' --- .../tilt/es6_module_transpiler_template.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 c1a4cacc99e..f31b8bdfaa1 100644 --- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb @@ -70,7 +70,13 @@ module Tilt # resolve based API. if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /discourse\/(controllers|components|views)\/(.*)/ type = Regexp.last_match[1] - class_name = Regexp.last_match[2].gsub(/[\-\/]/, '_').classify + file_name = Regexp.last_match[2].gsub(/[\-\/]/, '_') + class_name = file_name.classify + + # Rails removes pluralization when calling classify + if file_name.end_with?('s') && (!class_name.end_with?('s')) + class_name << "s" + end @output << "\n\nDiscourse.#{class_name}#{type.classify} = require('#{scope.logical_path}').default" end