diff --git a/build-client.js b/build-client.js
index bfd22c01..bec8ad7a 100644
--- a/build-client.js
+++ b/build-client.js
@@ -35,10 +35,23 @@ function loadLocs() {
return r
}
+function loadMustaches () {
+ // Loading mustache templates, dans filling constants.
+ const r = []
+ r['MUSTACHE_CONFIGURATION_HOME'] = loadMustache('client/common/configuration/templates/home.mustache')
+ r['MUSTACHE_CONFIGURATION_CHANNEL'] = loadMustache('client/common/configuration/templates/channel.mustache')
+ return r
+}
+
+function loadMustache (file) {
+ const filePath = path.resolve(__dirname, file)
+ return JSON.stringify(fs.readFileSync(filePath).toString())
+}
+
const define = Object.assign({
PLUGIN_CHAT_PACKAGE_NAME: JSON.stringify(packagejson.name),
PLUGIN_CHAT_SHORT_NAME: JSON.stringify(packagejson.name.replace(/^peertube-plugin-/, ''))
-}, loadLocs())
+}, loadLocs(), loadMustaches())
const configs = clientFiles.map(f => ({
entryPoints: [ path.resolve(__dirname, 'client', f + '.ts') ],
diff --git a/client/@types/global.d.ts b/client/@types/global.d.ts
index ed734f6b..6b382490 100644
--- a/client/@types/global.d.ts
+++ b/client/@types/global.d.ts
@@ -1,6 +1,10 @@
declare const PLUGIN_CHAT_PACKAGE_NAME: string
declare const PLUGIN_CHAT_SHORT_NAME: string
+// Constants that begins with "MUSTACHE_" are mustache templates, and are built by build-client.js.
+declare const MUSTACHE_CONFIGURATION_HOME: string
+declare const MUSTACHE_CONFIGURATION_CHANNEL: string
+
// Constants that begins with "LOC_" are loaded by build-client.js, reading the english locale file.
// See the online documentation: https://johnxlivingston.github.io/peertube-plugin-livechat/contributing/translate/
declare const LOC_ONLINE_HELP: string
diff --git a/client/common/configuration/templates/channel.mustache b/client/common/configuration/templates/channel.mustache
new file mode 100644
index 00000000..341f2731
--- /dev/null
+++ b/client/common/configuration/templates/channel.mustache
@@ -0,0 +1,185 @@
+
+
+ {{title}}:
+
+ {{channelConfiguration.channel.displayName}}
+ {{channelConfiguration.channel.name}}
+
+ {{{helpButton}}}
+
+
{{description}}
+
+
diff --git a/client/common/configuration/templates/channel.ts b/client/common/configuration/templates/channel.ts
index 474ccbf8..79020065 100644
--- a/client/common/configuration/templates/channel.ts
+++ b/client/common/configuration/templates/channel.ts
@@ -23,197 +23,7 @@ async function renderConfigurationChannel (
await fillViewHelpButtons(registerClientOptions, view)
await fillLabels(registerClientOptions, view)
- const content = Mustache.render(`
-
-
- {{title}}:
-
- {{channelConfiguration.channel.displayName}}
- {{channelConfiguration.channel.name}}
-
- {{{helpButton}}}
-
-
{{description}}
-
-
- `, view) as string
+ const content = Mustache.render(MUSTACHE_CONFIGURATION_CHANNEL, view) as string
rootEl.innerHTML = content
diff --git a/client/common/configuration/templates/home.mustache b/client/common/configuration/templates/home.mustache
new file mode 100644
index 00000000..da0099e8
--- /dev/null
+++ b/client/common/configuration/templates/home.mustache
@@ -0,0 +1,25 @@
+
+
{{title}}
+
{{description}}
+
{{please_select}}
+
+
diff --git a/client/common/configuration/templates/home.ts b/client/common/configuration/templates/home.ts
index 99eaf2b7..fff4e190 100644
--- a/client/common/configuration/templates/home.ts
+++ b/client/common/configuration/templates/home.ts
@@ -40,33 +40,7 @@ async function renderConfigurationHome (registerClientOptions: RegisterClientOpt
channels: channels.data
}
- return Mustache.render(`
-
-
{{title}}
-
{{description}}
-
{{please_select}}
-
-
- `, view) as string
+ return Mustache.render(MUSTACHE_CONFIGURATION_HOME, view) as string
} catch (err: any) {
peertubeHelpers.notifier.error(err.toString())
return ''