mirror of
https://github.com/discourse/discourse.git
synced 2025-04-16 20:59:06 +08:00
FIX: Backwards compatibility layer was not handling constants that ended
with 's'
This commit is contained in:
parent
1ed56eba7a
commit
5bbe938e82
@ -70,7 +70,13 @@ module Tilt
|
|||||||
# resolve based API.
|
# resolve based API.
|
||||||
if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /discourse\/(controllers|components|views)\/(.*)/
|
if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /discourse\/(controllers|components|views)\/(.*)/
|
||||||
type = Regexp.last_match[1]
|
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"
|
@output << "\n\nDiscourse.#{class_name}#{type.classify} = require('#{scope.logical_path}').default"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user