【发布时间】:2015-03-25 17:29:24
【问题描述】:
我希望能够在存储在 yml 语言环境文件中的字符串中插入变量。我想出如何做到这一点的唯一方法是使用正则表达式。
例如在 en.yml 我有
---
en:
byline: "By <strong>{{author}}</strong>"`
然后在我的 erb 文件中:
<%= t(:byline).gsub!(/{{author}}/, current_page.data.author) %>
有更简单的方法吗?
【问题讨论】:
标签: ruby regex middleman string-interpolation