A platform for community discussion. Free, open, simple.
DEV: move raw handlebars to /raw-templates/ (#22574)
Godfrey Chan4d62c49e2012
diff --git a/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js b/app/assets/javascripts/discourse-common/addon/lib/raw-templates.jsindex b979d7c8fff..5a8bd75e100 100644--- a/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js+++ b/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js@@ -1,4 +1,5 @@import { getResolverOption } from "discourse-common/resolver";+import require from "require";export const __DISCOURSE_RAW_TEMPLATES = {};@@ -45,11 +46,8 @@ export function buildRawConnectorCache(findOutlets) {}export function eagerLoadRawTemplateModules() {- for (const [key, value] of Object.entries(requirejs.entries)) {- if (- key.includes("/templates/") &&- value.deps.includes("discourse-common/lib/raw-templates")- ) {+ for (const key of Object.keys(requirejs.entries)) {+ if (key.includes("/raw-templates/")) {require(key);}}diff --git a/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js b/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.jsindex 06dce159431..ec2091aeac8 100644--- a/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js+++ b/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js@@ -141,9 +141,9 @@ TemplateCompiler.prototype.processString = function (string, relativePath) {if (pluginName) {filename = relativePath.replace(`discourse/plugins/${pluginName}/`, "")- .replace(/^(discourse\/)?templates\//, "javascripts/");+ .replace(/^(discourse\/)?raw-templates\//, "javascripts/");} else {- filename = relativePath.replace(/^templates\//, "");+ filename = relativePath.replace(/^raw-templates\//, "");}filename = filename.replace(/\.hbr$/, "");diff --git a/app/assets/javascripts/discourse-plugins/index.js b/app/assets/javascripts/discourse-plugins/index.jsindex dbf4f56c6be..a30535a4b49 100644--- a/app/assets/javascripts/discourse-plugins/index.js+++ b/app/assets/javascripts/discourse-plugins/index.js@@ -15,9 +15,16 @@ function fixLegacyExtensions(tree) {getDestinationPath: function (relativePath) {if (relativePath.endsWith(".es6")) {return relativePath.slice(0, -4);- } else if (relativePath.endsWith(".raw.hbs")) {- return relativePath.replace(".raw.hbs", ".hbr");+ } else if (relativePath.includes("/templates/")) {+ if (relativePath.endsWith(".raw.hbs")) {+ relativePath = relativePath.replace(".raw.hbs", ".hbr");+ }++ if (relativePath.endsWith(".hbr")) {+ return relativePath.replace("/templates/", "/raw-templates/");+ }}+return relativePath;},});diff --git a/app/assets/javascripts/discourse/app/templates/badge-selector-autocomplete.hbr b/app/assets/javascripts/discourse/app/raw-templates/badge-selector-autocomplete.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/badge-selector-autocomplete.hbrrename to app/assets/javascripts/discourse/app/raw-templates/badge-selector-autocomplete.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/category-selector-autocomplete.hbr b/app/assets/javascripts/discourse/app/raw-templates/category-selector-autocomplete.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/category-selector-autocomplete.hbrrename to app/assets/javascripts/discourse/app/raw-templates/category-selector-autocomplete.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/category-tag-autocomplete.hbr b/app/assets/javascripts/discourse/app/raw-templates/category-tag-autocomplete.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/category-tag-autocomplete.hbrrename to app/assets/javascripts/discourse/app/raw-templates/category-tag-autocomplete.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/emoji-selector-autocomplete.hbr b/app/assets/javascripts/discourse/app/raw-templates/emoji-selector-autocomplete.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/emoji-selector-autocomplete.hbrrename to app/assets/javascripts/discourse/app/raw-templates/emoji-selector-autocomplete.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/flat-button.hbr b/app/assets/javascripts/discourse/app/raw-templates/flat-button.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/flat-button.hbrrename to app/assets/javascripts/discourse/app/raw-templates/flat-button.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/group-selector-autocomplete.hbr b/app/assets/javascripts/discourse/app/raw-templates/group-selector-autocomplete.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/group-selector-autocomplete.hbrrename to app/assets/javascripts/discourse/app/raw-templates/group-selector-autocomplete.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/hashtag-autocomplete.hbr b/app/assets/javascripts/discourse/app/raw-templates/hashtag-autocomplete.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/hashtag-autocomplete.hbrrename to app/assets/javascripts/discourse/app/raw-templates/hashtag-autocomplete.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/action-list.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/action-list.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/action-list.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/action-list.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/activity-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/activity-column.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/activity-column.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/activity-column.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/category-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/category-column.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/category-column.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/category-column.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/participant-groups.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/participant-groups.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/participant-groups.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/participant-groups.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/post-count-or-badges.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/post-count-or-badges.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/post-count-or-badges.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/post-count-or-badges.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/posters-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/posters-column.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/posters-column.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/posters-column.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/posts-count-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/posts-count-column.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/posts-count-column.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/posts-count-column.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/topic-excerpt.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/topic-excerpt.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/topic-excerpt.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/topic-excerpt.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/topic-list-item.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/topic-list-item.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/topic-list-item.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/topic-list-item.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/unread-indicator.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/unread-indicator.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/unread-indicator.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/unread-indicator.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/list/visited-line.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/visited-line.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/list/visited-line.hbrrename to app/assets/javascripts/discourse/app/raw-templates/list/visited-line.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/mobile/list/topic-list-item.hbr b/app/assets/javascripts/discourse/app/raw-templates/mobile/list/topic-list-item.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/mobile/list/topic-list-item.hbrrename to app/assets/javascripts/discourse/app/raw-templates/mobile/list/topic-list-item.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/post/poster-avatar.hbr b/app/assets/javascripts/discourse/app/raw-templates/post/poster-avatar.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/post/poster-avatar.hbrrename to app/assets/javascripts/discourse/app/raw-templates/post/poster-avatar.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/topic-list-header-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/topic-list-header-column.hbrrename to app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/topic-list-header.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-list-header.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/topic-list-header.hbrrename to app/assets/javascripts/discourse/app/raw-templates/topic-list-header.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/topic-post-badges.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-post-badges.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/topic-post-badges.hbrrename to app/assets/javascripts/discourse/app/raw-templates/topic-post-badges.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/topic-status.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-status.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/topic-status.hbrrename to app/assets/javascripts/discourse/app/raw-templates/topic-status.hbrdiff --git a/app/assets/javascripts/discourse/app/templates/user-selector-autocomplete.hbr b/app/assets/javascripts/discourse/app/raw-templates/user-selector-autocomplete.hbrsimilarity index 100%rename from app/assets/javascripts/discourse/app/templates/user-selector-autocomplete.hbrrename to app/assets/javascripts/discourse/app/raw-templates/user-selector-autocomplete.hbrdiff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rbindex f67009bec3c..c4d15e67558 100644--- a/lib/theme_javascript_compiler.rb+++ b/lib/theme_javascript_compiler.rb@@ -97,8 +97,14 @@ class ThemeJavascriptCompilertree.transform_keys! do |filename|if filename.ends_with? ".js.es6"filename.sub(/\.js\.es6\z/, ".js")- elsif filename.ends_with? ".raw.hbs"- filename.sub(/\.raw\.hbs\z/, ".hbr")+ elsif filename.include? "/templates/"+ filename = filename.sub(/\.raw\.hbs\z/, ".hbr") if filename.ends_with? ".raw.hbs"++ if filename.ends_with? ".hbr"+ filename.sub(%r{/templates/}, "/raw-templates/")+ else+ filename+ endelsefilenameend@@ -168,7 +174,7 @@ class ThemeJavascriptCompilerelsif extension == "hbs"append_ember_template(module_name, content)elsif extension == "hbr"- append_raw_template(module_name.sub("discourse/templates/", ""), content)+ append_raw_template(module_name.sub("discourse/raw-templates/", ""), content)elseappend_js_error(filename, "unknown file extension '#{extension}' (#{filename})")end