{ "id": "173983", "key": "ALOY-1700", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2019-08-06T18:17:13.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "fmiao", "key": "fmiao", "displayName": "Feon Sua Xin Miao", "active": true, "timeZone": "America/Vancouver" }, "updated": "2021-01-20T13:46:47.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "12326", "name": "XML", "description": "View XML and parsing" } ], "description": "Add support for tag in View XML files that would simply output the code from the body of the element into the auto-generated controller.\r\n\r\nAlloy PR: https://github.com/appcelerator/alloy/pull/937\r\n\r\nCode can be added by src attribute:\r\n\r\n{code:xml}\r\n\r\n{code}\r\n\r\nOr by both:\r\n\r\n\r\n{code:xml}\r\n\r\n{code}\r\n\r\nIn the last case, it will put the code from the source file above the code from the body text.\r\n\r\nThe code will then be added to the auto-generated code that is put into the JavaScript controller.\r\n", "attachment": [], "flagged": false, "summary": "Add support for \r\n{code}\r\n\r\n\r\nThe debugger seemed to work fine and dropped me in here where I would expect:\r\n\r\n\r\n{code:java}\r\n// Generated UI code\r\n console.error('you are here in index.xml');\r\n debugger;\r\n\r\n $.__views[\"index\"] && $.addTopLevelView($.__views[\"index\"]);\r\n $.__views[\"index\"] = Ti.UI.createWindow(\r\n { backgroundColor: \"red\", top: 100, id: \"index\" });\r\n{code}\r\n\r\n\r\n\r\n", "updateAuthor": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2020-01-24T15:41:45.000+0000", "updated": "2020-01-24T15:41:45.000+0000" }, { "id": "453808", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Currently there is nothing to debug in an XML view, the only thing we have to worry about exposing the controller code to the debugger.\r\n\r\nMy concern here is the complication of trying to generate a sourcemap that is a combination of that the xml file and the js file. Handling mapping that back to the file in Studio/VS Code/Chrome/Safari) etc.\r\n\r\nWe could just say \"oh you can't debug that code, put it in a controller and you can\", but honestly I'd rather not add a feature than compromise on the developer experience we offer.", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2020-01-24T15:42:25.000+0000", "updated": "2020-01-24T15:42:25.000+0000" }, { "id": "453809", "author": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "updateAuthor": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2020-01-24T15:55:10.000+0000", "updated": "2020-01-24T15:55:10.000+0000" }, { "id": "453810", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "I meant people don't directly debug in XML (i.e. set breakpoints on lines in the XML file, step through etc.). I get that the compiled code is a useful escape hatch for people to use when stumped, but we shouldn't be promoting working in compiled code.\r\n\r\n{{If you use Alloy, you understand that the XML, JavaScript, and TSS files get merged into one JavaScript file at compile time.}}, most people do, but first time users/people who don't care to dive in fully might not. We can't make those assumptions ", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2020-01-24T16:56:32.000+0000", "updated": "2020-01-24T16:56:32.000+0000" }, { "id": "454559", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "I was just looking through all my GitHub notifications and stumbled upon this. I have to agree with Ewan here and don't immediately see the value in this new tag. \r\n\r\nYou mentioned that it allows you to inject code anywhere during the XML view processing. It would be great if you can outline some use-cases where this is necessary so we get an idea why you need to do that. Just being able to randomly inject JavaScript in views feels kinda hacky and IMHO is against the whole view/controller concept that Alloy uses.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-03-05T15:31:03.000+0000", "updated": "2020-03-05T15:31:03.000+0000" }, { "id": "454597", "author": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "body": "I know! JavaScript and XML together! In the same file no less! It's crazy! Just like those like those crazy other frameworks like Vue and React or even HTML :D ", "updateAuthor": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2020-03-06T21:54:11.000+0000", "updated": "2020-03-06T21:54:11.000+0000" }, { "id": "454598", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "All those frameworks have a clear seperation between template and component code. You don't add a script tag to the template to mix in some vanilla JS. That's not how they work at all. What you are doing is basically the HTML script tag. In all those framework that would be executed during runtime in the browser, without any scope to the component. What you are doing is injecting JS code during compile time. That's something totally different, and AFAIK, none of those frameworks supports that.\r\n\r\nJust to be clear, i'm sure that there is some missing piece in Alloy that is the motivation for this. I'm just not convinced that a script tag that allows injecting code somewhere in the view is the proper solution. So again, some examples where this is necessary would be great to see what the actual problem is.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-03-06T22:20:08.000+0000", "updated": "2020-03-06T22:55:29.000+0000" }, { "id": "454599", "author": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "body": "The purpose of this, like most of the PRs I create, is to speed up coding time (as opposed to compile time). From what I've seen, coding usually takes a significant higher percentage of a developer's day than compiling so that is usually where I direct my efforts.\r\n\r\nI understand if you can't merge it. I am usually able to find another home for my PRs so that they can live a long and prosperous life in a parallel universe somewhere :D\r\n", "updateAuthor": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2020-03-06T23:20:02.000+0000", "updated": "2020-03-06T23:20:02.000+0000" }, { "id": "454607", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "{quote}The purpose of this, like most of the PRs I create, is to speed up coding time (as opposed to compile time). From what I've seen, coding usually takes a significant higher percentage of a developer's day than compiling so that is usually where I direct my efforts.{quote}\r\n\r\nI get that this is meant to improve developer experience, but again, do you have a real world example where this would be useful? I'm just trying to understand what specific problem you are trying to solve with this. The examples you posted are very simple and don't really explain why such a feature would be necessary.\r\n\r\n{quote}I understand if you can't merge it. I am usually able to find another home for my PRs so that they can live a long and prosperous life in a parallel universe somewhere {quote}\r\n\r\nThat's cool and all, but i would rather see us work together on Alloy instead of you just doing you own thing with Turbo. Some of your improvements made in Turbo were already merged back to Alloy. Some of them should better bet integrated into the SDK. Some of them need some evaluation/improvements before they can go into Alloy. Same for this PR. Ewan and I are not trying to shut your idea down per se, we are trying to understand what's the actual problem is, and if there may be a solution that fit's better into Alloys design principles.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2020-03-09T11:00:34.000+0000", "updated": "2020-03-09T11:00:34.000+0000" }, { "id": "458053", "author": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "body": "We already support injecting JavaScript inside xml tags. We have a {{}} tag for that, which can return anything UI based you want with any complexity you want, and can call any lib file. ", "updateAuthor": { "name": "topener", "key": "topener", "displayName": "Rene Pot", "active": true, "timeZone": "Europe/Berlin" }, "created": "2021-01-20T11:54:29.000+0000", "updated": "2021-01-20T11:54:29.000+0000" }, { "id": "458054", "author": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "body": "The script tag is much more than this. It doesn’t require you to return anything. Plus, any variables you set in that block are in scope for use within the rest of the view. ", "updateAuthor": { "name": "bhouse", "key": "bhouse", "displayName": "Brenton House", "active": true, "timeZone": "America/Chicago" }, "created": "2021-01-20T13:46:47.000+0000", "updated": "2021-01-20T13:46:47.000+0000" } ], "maxResults": 17, "total": 17, "startAt": 0 } } }