I have a YAML which includes some ERB blocks:
---
- id: "1"
pre: |
<%
a = rand(2..20)
b = rand(1..20)
%>
sentence: "The result of <%=a%> + <%=b%> is <%=a+b%>"
- id: "2"
pre: |
<%
a = rand(1..20)
b = 5
%>
sentence: "The fraction $\frac{<%=a%>}{<%=b%>}$ equals to $<%=Rational(a, b)%>$"
[many more]
---
I want to get element N, evaluate as ERB template and return as YAML string
Example: if we get element 1, I expected to get:
---
- id: "1"
pre: |
sentence: "The result of 3 + 4 is 7"
---