It's not clear what the "this" is that you want to do. The fragment you posted is not valid ERB, and it is problematic. The key to writing ERB templates is to recognize that what you are actually writing is ordinary Ruby code, but presented inside-out:
- Each span of text outside a scriptlet (<%[=]...%>) can be thought of as being a string argument to a 'print' call.
- Each expression scriptlet (<%= ... %>) can be thought of as providing a 'print' argument as a Ruby expression (the value of the expression within is printed to the output)
- Each command scriptlet <% ... %> provides ordinary Ruby code to appear between the 'print' statements implied by the other template elements; the value produced by executing that code is not emitted into the template output.
Template output can certainly be conditional. Here are two ways to do it:
Using an expression scriptlet:
cluster.name: <%= (fqdn == @qa) ? 'elastic-qa-cluster' : 'other-cluster' %>
Using command scriptlets:
cluster.name: <% if fqdn == @qa { %>elastic-qa-cluster<% } else { %>other-cluster<% }%>
John