-1

我如何将以下 Pinterest 标签转换为 rails link_to 标签,以便我可以动态创建链接

<a href="//www.pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg&description=Next%20stop%3A%20Pinterest" data-pin-do="buttonPin" data-pin-config="none"></a>
4

1 回答 1

3
url = "//www.pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg&description=Next%20stop%3A%20Pinterest"

link_to "Pinterest", url, { data: { pin_do: "buttonPin", pin_config: "none"} }

请注意,由于破折号,您需要在 'pin-do' 和 'pin-config' 周围加上引号。 更新:感谢@Stefan,我现在了解到 Rails 会自动将数据标签中的下划线转换为连字符。

参考:

于 2013-10-07T06:54:38.713 回答