DEV: Remove Discourse.RAW_TEMPLATES (#9630)

We were sharing `Discourse` both as an application object and a
namespace which complicated things for Ember CLI. This patch
moves raw templates into `__DISCOURSE_RAW_TEMPLATES` and adds
a couple helper methods to create/remove them.
This commit is contained in:
Robin Ward
2020-05-05 12:15:03 -04:00
committed by GitHub
parent 657facb1d5
commit 612284cef3
20 changed files with 75 additions and 53 deletions

View File

@ -112,19 +112,19 @@ describe ThemeJavascriptCompiler do
describe "#append_raw_template" do
let(:compiler) { ThemeJavascriptCompiler.new(1, 'marks') }
it 'adds the correct template to "Discourse.RAW_TEMPLATES"' do
it 'uses the correct template paths' do
template = "<h1>hello</h1>"
name = "/path/to/templates1"
compiler.append_raw_template("#{name}.raw", template)
expect(compiler.content.to_s).to include("Discourse.RAW_TEMPLATES[\"#{name}\"]")
expect(compiler.content.to_s).to include("addRawTemplate(\"#{name}\"")
name = "/path/to/templates2"
compiler.append_raw_template("#{name}.hbr", template)
expect(compiler.content.to_s).to include("Discourse.RAW_TEMPLATES[\"#{name}\"]")
expect(compiler.content.to_s).to include("addRawTemplate(\"#{name}\"")
name = "/path/to/templates3"
compiler.append_raw_template("#{name}.hbs", template)
expect(compiler.content.to_s).to include("Discourse.RAW_TEMPLATES[\"#{name}.hbs\"]")
expect(compiler.content.to_s).to include("addRawTemplate(\"#{name}.hbs\"")
end
end
end