FIX: Customization templates were not working with Glimmer2
This commit is contained in:
parent
3786d3679c
commit
889efe48be
|
@ -45,20 +45,27 @@ PLUGIN_API_JS
|
||||||
doc = Nokogiri::HTML.fragment(html)
|
doc = Nokogiri::HTML.fragment(html)
|
||||||
doc.css('script[type="text/x-handlebars"]').each do |node|
|
doc.css('script[type="text/x-handlebars"]').each do |node|
|
||||||
name = node["name"] || node["data-template-name"] || "broken"
|
name = node["name"] || node["data-template-name"] || "broken"
|
||||||
precompiled =
|
is_raw = name =~ /\.raw$/
|
||||||
if name =~ /\.raw$/
|
if is_raw
|
||||||
"require('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
|
template = "require('discourse-common/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
|
||||||
else
|
node.replace <<COMPILED
|
||||||
"Ember.HTMLBars.template(#{Barber::Ember::Precompiler.compile(node.inner_html)})"
|
<script>
|
||||||
end
|
(function() {
|
||||||
|
Discourse.RAW_TEMPLATES[#{name.sub(/\.raw$/, '').inspect}] = #{template};
|
||||||
node.replace <<COMPILED
|
})();
|
||||||
<script>
|
</script>
|
||||||
(function() {
|
|
||||||
Discourse.RAW_TEMPLATES[#{name.sub(/\.raw$/, '').inspect}] = #{precompiled};
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
COMPILED
|
COMPILED
|
||||||
|
else
|
||||||
|
template = "Ember.HTMLBars.template(#{Barber::Ember::Precompiler.compile(node.inner_html)})"
|
||||||
|
node.replace <<COMPILED
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
Ember.TEMPLATES[#{name.inspect}] = #{template};
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
COMPILED
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
doc.css('script[type="text/discourse-plugin"]').each do |node|
|
doc.css('script[type="text/discourse-plugin"]').each do |node|
|
||||||
|
|
Loading…
Reference in New Issue