aisingapore / TagUI

Free RPA tool by AI Singapore
Apache License 2.0
5.65k stars 585 forks source link

Steps { and } should not be used for step / code blocks #26

Closed kensoh closed 7 years ago

kensoh commented 7 years ago

ISSUE - In release v1.8, steps { and } are introduced to define steps and code blocks. This adds convenience and powerful automation when used with if/for/while/popup/frame.

The idea is replacing { with

// start of code block
{casper.then(function() {

And replacing } with

})}; // end of code block

The above replacements and some tracking logic will automatically take care of CasperJS code blocks formatting. However, as { and } can also be used in JavaScript to define code blocks, there can be situations where developers want to define custom functions or events which above auto-replacement will break their code. Unless they use js step to explicitly tell TagUI to treat that line as pure JavaScript and not to parse it as a TagUI step.

There should be a better way so that developers do not have to type js { or js } to explicitly treat the line as JavaScript, and normal users can define step/code blocks easily. Maybe checking [ and ] instead as the single character on the line as markers for start and end of step/code block.

kensoh commented 7 years ago

Reclassifying more appropriately as a bug because v1.8 may break the original design of users who have used { and } to mean traditional JavaScript code blocks.

kensoh commented 7 years ago

Thinking through, it seems that there is probably no existing use case which will encounter an issue with the above auto-replacement to casper context blocks. This is because lines in the automation flows are already by default in casper context.

Developers wanting to add custom functions would have to define them in tagui_header.js. Unless they manually close the casper context, define them, and reopen casper context. In that case using js step to explicitly declare as JavaScript code would work.

Readme should officially include js step. This should be a good balance between pro-developers flexibility and quick prototyping convenience.

kensoh commented 7 years ago

Closing and changing to enhancement category - adding js step officially to readme documentation.