Rails - 将正则表达式传递给清理方法允许的属性列表
是否可以将正则表达式传递到rails3中清理方法允许的html属性列表?在我的特殊情况下,我希望允许所有以 "data-"
开头的属性
在清理调用中
sanitize(my_string, :tags => %w(div span), :attributes => my_regular_expression)
或在 application.rb 中,例如
config.action_view.sanitized_allowed_attributes = 'id', 'style', my_regular_expression
Is it possible to pass regular expression to the list of allowed html attributes for sanitize method in rails3? In my particular situation I would like to allow all attributes starting with "data-"
Either on sanitize call
sanitize(my_string, :tags => %w(div span), :attributes => my_regular_expression)
or in application.rb like
config.action_view.sanitized_allowed_attributes = 'id', 'style', my_regular_expression
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯...计算机说不。
不过,这将是一个很棒的功能。您可以将其添加为 Rails 上的功能请求。
hmmm... computer says no.
Would be great feature, though. You could add it as a feature request on rails.