[ALOY-743] Alloy: Add proper dynamic loading of namespace objects
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-07-18T17:39:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.2.0, 2013 Sprint 15 |
Components | Runtime, XML |
Labels | alloy, compile, namespace, qe-testadded |
Reporter | Fokke Zandbergen |
Assignee | Tony Lukasavage |
Created | 2013-07-14T17:24:07.000+0000 |
Updated | 2013-07-22T23:21:39.000+0000 |
Description
The Alloyns
attribute can be used in a creative manner to load a CommonJS or native module to call the createTagName
method upon, since:
<MyComponent ns="require('my.module')" id="myId" />
Will compile to:
$.__views.myId = require('my.module').createMyComponent({ .. });
This works fine, but still feels hacky. I would propose to make a change to /Alloy/commands/compile/parsers/default.js
so that whenever a namespace is given like this:
<MyComponent ns="my.module" id="myId" />
The generated code would be:
if (typeof my.module === 'undefined') var myModule = require('my.module');
$.__views.myId = myModule.createMyComponent({ .. });
Attachments
File | Date | Size |
---|---|---|
Screen Shot 2013-07-18 at 1.09.50 PM.png | 2013-07-19T13:28:53.000+0000 | 16558 |