I have a YAML data file with information about some products.
One of the product fields is a description. In that description I have found the need to link to other products. The only way I could think of doing this is with the link_to helper but I am having trouble getting the description field to be rendered as a block of ERB code.
Data file (products.yml)
- Widget1
description: Widget1 is very similar to <%= link_to "widget2", data.products["Widget2"] %>
- Widget2
description: Has nice features.
View file (index.html.slim)
p
| Product description:
= function_to_render_erb(data.products["Widget1"].description)
Technically, the link_to is a bit more complicated because I have to run the product through my custom get_url() helper function, so it is more like link_to "widget2", get_url(data.products["Widget2"])
but I hope that won’t be an issue.
I am open to putting the description in a separate file and then storing the location of that file in the YAML data if that makes it easier.
What I am trying to do seems similar to what people do with markdown sometimes using
Tilt['markdown'].new { source }.render