I'm building a small static website using Ruby and Middleman. With Rails I've been able to safely encode email links with the mail_to helper and the encode: 'hex' option;

mail_to 'email@email.com', 'My Name', encode: 'hex'

But when I try this in Middleman using the same code I wind up with this in my HTML;

<a encode="hex" href="mailto:email@email.com">My Name</a>

Any suggestions? I tried adding actionpack to my gemfile, but that didn't help.

有帮助吗?

解决方案

Although both helpers from Middleman and Rails are called the same, they are actually not the same in code. Moreover, encode parameter has been removed from Rails 4 and you now have to require a separate gem to use it.

I think, your best option will be to look at the code in that gem and reimplement it as a separate helper for your Middleman project.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top