Skip to content

Instantly share code, notes, and snippets.

@jasonkneen
Last active November 28, 2016 14:26
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasonkneen/0f09114f4913c00512f9 to your computer and use it in GitHub Desktop.
Save jasonkneen/0f09114f4913c00512f9 to your computer and use it in GitHub Desktop.
In the latest TiAlloy you can specify a module tag against the <Alloy> element in XML and this will be used when creating any elements in the view, so you can override, customise etc. The problem is if you want to use multiple commonJS libraries, there's no support in the Alloy Tag -- you'd have to change the module attribute for each element --…
var o = {};
// include the modules you want - purposely did this as seperate lines so it's easier to comment out modules etc
_.extend(o, require("module1"));
_.extend(o, require("module2"));
_.extend(o, require("module3"));
// make available under a single export for use in <Alloy> tag
module.exports = o;
<Alloy module="elements">
<Window>
<Label>Hello!</Label>
</Window>
</Alloy>
@jasonkneen
Copy link
Author

So basically this allows you to have several files in your /lib folder that you can then have referenced for creating tag / elements. Basically the Window and Label elements will be processed by running through the "elements" module first, looking for .createWindow and .createLabel -- if none are found it defaults to Alloy / Ti defaults

@falkolab
Copy link

falkolab commented Sep 7, 2015

it would be nice like:

<Widget src="my.widget" module="lib.from.widget>
   <CustomTag />
</Widget>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment