create-modulo
Version:
Starter projects for Modulo.html - Ready for all uses - Markdown-SSG / SSR / API-backed SPA
30 lines (24 loc) • 1.1 kB
HTML
/* <script src=../Modulo.html></script><script type=f> */
// EXAMPLE - Globally executed JavaScript code
console.log('JavaScript Ready! See: static/js/main.js.htm')
// Example: A "isactive" helper that has special logic around sub dirs
modulo.templateFilter.isactive = function ifactive(row, cls = 'active') {
if (modulo.filePath.includes('/')) { // in a directory!
for (const [ prefix ] of modulo.definitions.nestedpaths.data) { // look for subpaths
if (row[0].startsWith(prefix + '/')) { // in a directory!
return modulo.filePath.startsWith(prefix + '/') ? cls : '';
}
}
} else if (modulo.filePath === row[0]) {
return cls;
}
return ''; // empty string otherwise
}
// EXAMPLE - CUSTOM COMPONENT PART
//modulo.part.mycustomcpart = class MyCustomCPart {
// prepareCallback() { console.log('before render', this.attrs, this.element) }
// updateCallback() { console.log('after render') }
//}
// (To use, in a component:)
//<Component name="MyComponent"> ...
// <MyCustomCPart foo="foobar"></MyCustomCpart>