[ALOY-152] Add an Include and Require element see description

GitHub Issuen/a
Resolution Date2012-08-07T21:48:05.000+0000
Affected Version/s2012 Sprint 16
Fix Version/s2012 Sprint 16, Release 3.0.0
ComponentsRuntime, XML
ReporterRussell McMahon


After having a lengthy discussion with Tony and Rick we may want to support both an Inculde and a Require element as the two elements provide quite disparate featues. Rick or Tony feel free to expand if you think I missed something. index.xml Would take the markup that is in myMarkup.xml and make that markup avaialable as it is under it's parent element "win1". This is good for quick reuse of fragments of markup (XML). If say within myMarkup.xml you had a Button say with id "btn1" then within the index.js controller the Ti.UI.Button proxy is accessed through "btn1". There is no associated style On the other hand index.xml Would take the controller (trifecto) and add that to the index.js controller. Styles and the source controller myView.js of myView is maintained. It's like a var view1 = require("myView").create() being done automatically for you and the view hierarchy still under "win1". If myView had a Button with id "btn1" In index.js controller the developer would access the button through "view1.btn1". The advantage here is trifecto reuse and never any id collisions. If the name attribute is missing we can use the view name. From Rick B Include: https://gist.github.com/3219597 Require: https://gist.github.com/3219595

other suggestions

<!-- for widgets -->
<Require widgetId="widgetId"/>


  1. Tony Lukasavage 2012-08-07 Originally from Russell McMahon: Since both widgets and views will use the Require element we should have a type attribute. If type is missing default to type="view" /* require brings in trifecto */
  2. Tony Lukasavage 2012-08-07 OK, but we'll need to use something else for the widget id, since *id* is reserved for Alloy use. How about we use *src* for both cases and let the *type* determine how each should be handled?

    option #1

       <Require type="widget" src="widgetId"/>
       <Require type="view" src="path/to/view"/> 
    I actually like the idea of doing this initially:

    option #2

       <Require widget="widgetId"/>
       <Require view="path/to/view"/> 
    but it starts introducing more reserved keywords. It's also not as flexible as using *type* if we ended up adding more types. But... man does it look pretty, clean, and expressive. I don't know, I might be talking myself back into option #2 as I'm typing. Thoughts? Also, as far as , should it just look like this?
       <Include src="path/to/any/xml/file"/>
       <!-- example -->
       <Include src="views/myMarkup.xml"/>
    An important distinction is that will happen at compile time, where will generate runtime code for accessing the generated controllers.
  3. Russell McMahon 2012-08-07 Option #1 looks to be best.

JSON Source