I’m developing an interactive application and would like to include a select list in the form.yml. However, instead of hardcoding the options in the dropdown, I would like them to be dynamically generated from a system command. Here is what I have tried (which does not work):
project_group:
label: "Project group"
widget: "select"
options:
<%= `get_groups command`.split('\n').each do |group| %>
- <%= group %>
<% end %>
Is this sort of thing supported? If so, am I doing something wrong? My guess is that since form.yml is not referenced as ending in .erb, it is not rendered by the templating engine. Is that assumption correct?
You can also use erb in submit.yml - rename it to submit.yml.erb. And any file in the template directory, if it has .erb appended to it, that will get rendered and then a new file added to the copied template with the same filename sans the .erb extension
Thank you, this is great. I was already using submit.yml.erb, but I didn’t know that I could force ERB to render any file in the application folder just by adding the extension .erb. Everything is working as expected now.