I'm not sure if this is a RM bug, a Chef Cookbook RM plugin bug or if I'm doing something wrong in terms of erb or HCL syntax and RM is picking up on my mistake. This is a snippet of the erb (ie myfile.hcl.erb) file that generates a configuration file:
server = false
list_of_things = <%= @my_array.to_s %>
script_checks = true
RM marks the line `script_checks` with a syntax error. The tooltip reads `'(', <boolean>, <identifier>, <null>, <operator>, or <string literal> expected, got '='`
I _think_ this is because the syntax parser doesn't like the previous line. To the parser `<%= ... %>` doesn't look like a proper value type (String, Array, Hash, etc) but just looks like some weird unknown object type hanging out there. If the RH side of `list_of_things` is wrapped in quotes or brackets, RM is happy.
That's an issue because the rendered value needs to be written out as an HCL array. It needs to render literally as `list_of_things = [ "a", "b", "c" ]`. If wrapped in quotes, the HCL parser will assume the whole thing is a single string, and if wrapped in brackets, will treat it as a 3 item array nested in a 1 item array `[ [ "a", "b", "c" ] ]`
I don't think RM's syntax parser is strictly wrong. It has no idea that the rendered result will be correct, only that it looks like the HCL format is bad - an so marks the line and the file as having errors. The runtime ERB generator is fine with this as written, and the file renders properly.
Is this an issue with the RM parser, or is there another way I should be approaching this than `<%= @myarray.to_s %>` to get the rendered result I need, or some way to hint to RM that the final value will be a proper array?
edit: sorry for the inline code mess. there doesn't appear to be a way to do inline code format style, only block-level.