Sometimes it's more convenient to print in <%%>. How to do it in Rails?
In ERB: The <% %> signify that there is Ruby code here to be interpreted. The <%= %> says output the ruby code, ie display/print the result. So it seems you need to use the extra = sign if you want to output in a standard ERB file.
An ERB template looks like a plain-text document interspersed with tags containing Ruby code. When evaluated, this tagged code can modify text in the template. Puppet passes data to templates via special objects and variables, which you can use in the tagged Ruby code to control the templates' output.
Code in <% %> (without equal) is executed "with no substitution back into the output" means you want to execute code WITHOUT any output, like a loop and the best part is, it can be used with a non ruby code.
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-concat
Should be what you are looking for.
E.g. the following statement using concat
:
<% concat "Output" %>
is equivalent to:
<%= "Output" %>
In ERB: The <% %> signify that there is Ruby code here to be interpreted. The <%= %> says output the ruby code, ie display/print the result.
So it seems you need to use the extra = sign if you want to output in a standard ERB file.
Otherwise, you could look at alternatives to ERB which require less syntax,.. maybe try something like HAML. http://haml-lang.com/tutorial.html
Example: # ERB <strong><%= item.title %></strong> # HAML %strong= item.title
Is that more convenient?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With