Release v0.7.0 - mitzerh/modulr-js GitHub Wiki
- page-level markup calls for modules added.
STATUS: QA testing
This allows you to load modules without the need for Modulr.require()
or loading via dependencies.
Example:
<ul data-modulr-module="sites:modules/foo-bar"></ul>
The data-* attribute to use, as noted is data-modulr-module
where it's value is the module definition name.
Accessing the DOM from the module is via it's resource property by adding the dependency "module->resource"
Example:
Modulr.define("sites:modules/foo-bar", [
"require",
"module->resource"
], function(require, resource) {
console.log("RESOURCES OF THIS MODULE >>", resource);
console.log("DOM targets using this module >>", rsource.dom);
});
When module->resource
is called from a module that does not have a page-level module execution, it returns null
.
NOTE: For now, the only way you can access the resource
object is passing it via the function arguments. You cannot pass it through require() dependency calls:
. . .
"require",
"module->resource"
], function(require) {
// this will not work
var resource = require("module->resource");
. . .
});