[ad_1]
Rails 7 / Ruby 3
I’m currently working on a site that requires code examples to be displayed on a page – I can get these to display utilising the extra %
character trick, however, for some of the examples I need to have a variable within them that is resolved (e.g. like the users’ own API key etc…).
Consider I have @variable = "Resolved Variable"
<%%= link_to @variable, variable_path %>
Outputs on the page explicitly as
<%= link_to @variable, variable_path %>
But I really need the @variable
to resolve and show on the page as:
<%= link_to "Resolved Variable", variable_path %>
I’ve tried all kinds of escaping the variable, but it seems that <%%=
ensures that nothing following it can be resolved.
Any ideas?
[ad_2]