aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/handlebars.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-10-13 21:50:29 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2019-10-13 21:50:29 +0300
commitf3ab7673f98f8721030d5513459e5e842b812e80 (patch)
treec0e08bb159adf2882f1aaa6e30c3fbe010749628 /ext/bg/js/handlebars.js
parent7bae3824e74461fbd5c9f66f921b05a47a40cbf4 (diff)
add css class for dictionary name
Can be used for dictionary specific styling
Diffstat (limited to 'ext/bg/js/handlebars.js')
-rw-r--r--ext/bg/js/handlebars.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js
index 66d5fa2b..92764a20 100644
--- a/ext/bg/js/handlebars.js
+++ b/ext/bg/js/handlebars.js
@@ -75,6 +75,10 @@ function handlebarsMultiLine(options) {
return options.fn(this).split('\n').join('<br>');
}
+function handlebarsSanitizeCssClass(options) {
+ return options.fn(this).replace(/[^_a-z0-9\u00a0-\uffff]/ig, '_');
+}
+
function handlebarsRegisterHelpers() {
if (Handlebars.partials !== Handlebars.templates) {
Handlebars.partials = Handlebars.templates;
@@ -83,6 +87,7 @@ function handlebarsRegisterHelpers() {
Handlebars.registerHelper('furiganaPlain', handlebarsFuriganaPlain);
Handlebars.registerHelper('kanjiLinks', handlebarsKanjiLinks);
Handlebars.registerHelper('multiLine', handlebarsMultiLine);
+ Handlebars.registerHelper('sanitizeCssClass', handlebarsSanitizeCssClass);
}
}