3 const { TemplateHelper
} = require('@squeep/html-template-helper');
7 * Escape a string to be suitable as a CSS name.
8 * @param {String} unsafeName
11 function escapeCSS(unsafeName
) {
12 return unsafeName
.replace(/([^0-9a-zA-Z-])/g, '\\$1');
17 * Given a pair of Array tuples containing scope names and scope details,
18 * return the comparison between the two, for sorting.
19 * Scopes are sorted such that they are grouped by application, then name.
20 * Empty applications are sorted ahead of extant applications.
25 function scopeCompare([aScope
, aDetails
], [bScope
, bDetails
]) {
26 const { application: aApp
} = aDetails
;
27 const { application: bApp
} = bDetails
;
28 if ((aApp
|| bApp
) && (aApp
!== bApp
)) {
41 if (aScope
> bScope
) {
43 } else if (aScope
< bScope
) {
51 * Populate common navLinks for page templates.
52 * @param {Number} pagePathLevel
54 * @param {Object} options
56 function navLinks(pagePathLevel
, ctx
, options
) {
57 if (!options
.navLinks
) {
58 options
.navLinks
= [];
60 const rootPath
= '../'.repeat(pagePathLevel
);
62 if (options
.pageIdentifier
!== 'admin') {
63 options
.navLinks
.push({
65 href: `${rootPath}admin/`,
68 if (options
.pageIdentifier
!== 'ticketProffer') {
69 options
.navLinks
.push({
71 href: `${rootPath}admin/ticket`,
76 module
.exports
= Object
.assign(Object
.create(TemplateHelper
), {