[ALOY-1018] Add defaultNamespace or module attribute to Alloy Tag
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2014-10-30T05:44:53.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.7.0 |
Components | XML |
Labels | n/a |
Reporter | Jason Kneen |
Assignee | Tim Poulsen |
Created | 2014-05-16T17:48:30.000+0000 |
Updated | 2015-11-03T21:41:11.000+0000 |
Description
Alloy currently has a feature of specifying a module attribute against tags, allowing a custom JS module to be used to create the elements, enabling developers to return modified or different elements.
e.g:
1) You mean
<Alloy module="ui" >
without.js
2) This would require the compiler to require the module and check ifcreate[Tag]
exists. 3)module
rocks: http://fokkezb.nl/2013/10/21/cross-platform-ui/1. Yes of course 2. Yep 3. Good plug.
So, I can implement this. However, since I don't know which of your tags would implement some custom functionality, I have to basically copy the module attribute to every tag. This, naturally breaks the runtime code generated for every tag that your custom function doesn't implement a specific
create
function for. To fix that, I have to implement some pretty inefficient code with lots of duplication. For example, this:generates this:
I'm sure I could optimize this more than I have here. Still, the change is going to make for rather different code generated if you do or don't use the default module attribute. I hesitate to implement such a minor productivity enhancement that comes with the potential for such results. Thoughts? Suggestions?
Or:
like it
Right, like I said, I can do some optimization. But is the slowdown of a runtime check for every API call in a controller worth it for the few minutes of developer time saved by not having to specify module="foo" for those couple of components for which you'll be using custom modules for?
I think treat this like the Dynamic TSS in Alloy - If not used sparingly it can be an overhead. If a developer wants to go this route then it's their choice? For my TabGroup concept, I have to add the attribute to the TabGroup, Tab and Window tags. Wouldn't this have the same overhead as adding it once to the Alloy Tag wrapping the TabGroup?
I'd be interested in seeing it added to run some simple speed tests - see how much it does affect performance.
Can you grab from here and do some tests? https://github.com/skypanther/alloy/tree/ALOY-1018 (generated code now matches Fokke's comment)
I'm in France on a beach so if you don't mind [~jasonkneen], please test twice - one for me ;)
PR https://github.com/appcelerator/alloy/pull/614 Functional test: Run the included ALOY\-1018 test app. You should get an app with a blue-bordered button and a pink-background label which were created with custom tags defined in the testmod module.
Additional test note: 1. {color:blue} Blue {color} bordered custom button on iOS 2. {color:green} Green {color} bordered custom button on Android
PR merged.
Not work for widget children. Work only if set module attribute of Alloy tag.
Why would you add custom tags in a widget?
@jasonkneen for example:
In widget lib folder:
Then use args.children to initialize widget.
Don't get why you need the widget. Just use the custom tags directly in your app. But I guess you have good reason so good luck!
Anyway if I can add tags to the widget why I can't use module for this tags ?