{"action":"opened","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/18008","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/18008/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/18008/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/18008/events","html_url":"https://github.com/hashicorp/terraform/issues/18008","id":321419238,"number":18008,"title":"Feature Request: splitwords interpolation function","user":{"login":"joshringer","id":504709,"avatar_url":"https://avatars2.githubusercontent.com/u/504709?v=4","gravatar_id":"","url":"https://api.github.com/users/joshringer","html_url":"https://github.com/joshringer","followers_url":"https://api.github.com/users/joshringer/followers","following_url":"https://api.github.com/users/joshringer/following{/other_user}","gists_url":"https://api.github.com/users/joshringer/gists{/gist_id}","starred_url":"https://api.github.com/users/joshringer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshringer/subscriptions","organizations_url":"https://api.github.com/users/joshringer/orgs","repos_url":"https://api.github.com/users/joshringer/repos","events_url":"https://api.github.com/users/joshringer/events{/privacy}","received_events_url":"https://api.github.com/users/joshringer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-09T03:36:45Z","updated_at":"2018-05-09T03:36:45Z","closed_at":null,"author_association":"NONE","body":"There is already some functionality in place to identify words in strings, namely the `title(string)` function. I think it would be useful to provide this as a separate interpolation function `splitwords(string)`, which splits a string into a list of word strings.\r\n\r\nThis would provide a flexible way of converting strings in cases where one requires a particular format for a value.\r\nE.g.\r\n* Converting to CamelCase: `\"${join(\"\", splitwords(title(var.name)))}\"`\r\n* Converting to snake_case: `\"${join(\"_\", splitwords(var.name))}\"`\r\n\r\nCurrently, the best—somewhat dirty—way of achieving this that I can think of is a long list of `split`+`join`s:\r\n```\r\n\"${join(\"_\", split(\" \", join(\" \", split(\"_\", join(\" \", split(\"-\", var.name))))))}\"\r\n```"}}
{"actor":{"display_login":"joshringer"}}