Jasonette / Jasonette/JASONETTE-iOS

Action options get instantiated before execution if the template doesn't contain a variable

Open
#158 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.2k
Forks
347
PR merge metrics
No merged PRs in 30d

Description

In the following example the template expression gets instantiated because it immediately evaluates to a fixed value.

```
"actions": {
"$pull": {
"type": "$set",
"options": {
"color": "{{var letters = '0123456789ABCDEF'; var color = '#'; for (var i = 0; i < 6; i++ ) { color += letters[Math.floor(Math.random() * 16)]; } return color;}}"
},
"success": {
"trigger": "update_color"
}
}
}
```

Currently I have to do something like this to ensure that the options stay un-instantiated until the execution point (because of the `$get` variable)

```
"actions": {
"$pull": {
"type": "$set",
"options": {
"color": [{
"{{#if 'color' in $get}}": "{{var letters = '0123456789ABCDEF'; var color = '#'; for (var i = 0; i < 6; i++ ) { color += letters[Math.floor(Math.random() * 16)]; } return color;}}"
}, {
"{{#else}}": "#ffffff"
}]
},
"success": {
"trigger": "update_color"
}
}
}
```

Other than this it works fine but it can be confusing in a few edge cases like this, so need to come up with a solution so that options NEVER get instantiated regardless of context

Contributor guide

Open the contributing guide

Research direction

Start by tracing where action templates and their options are instantiated, comparing the direct expression with the `$get` workaround shown in the issue. Confirm that option expressions remain uninstantiated until action execution in both contexts, and add or update coverage for the random-color example if the repository has matching tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.