JavaScript Modules

CMintS is using Node.js-style modules and makes Theme functionality implementation modular out of the box. All that magic is done using browserify.

JavaScript files that are placed in theme/js directory and don't have starting _ in the filename ex.: _contextMenu.js are being compiled into the public/js directory.


/* theme/js/_contextMenu.js */
const toggleContextMenu = (buttonElem) =>
  const contextMenus = buttonElem.closest(".contextMenu");
  if (contextMenus)

module.exports.toggleContextMenu = toggleContextMenu;


/* theme/js/main */
const {toggleContextMenu} = require("./_contextMenu");

document.body.addEventListener("click", (e)=>
}, false);

The example above will be compiled into the public/js/main.js and can be included into the Theme's layout:

<!DOCTYPE html>
<html lang="<%= page.locale %>">
  <script src="/js/main.js" defer></script>