我使用ActionText来呈现一些丰富的文本,并且由于某些原因,我在使用actiontext提供的部分向呈现的部分添加额外元素时受到限制。
我要求附加的图像被包装在表格元素周围,这样就可以在Outlook中的电子邮件中正确地呈现它们。在我输入的部分中,ActionText似乎总是忽略任何额外的元素。有人知道为什么会发生这种事吗?有没有办法解决这个问题?
这是我的部分,表元素被忽略了:
/views/active_storage/blobs/_blob.html.erb
<table>
<Tr>
<td>
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %> text-center">
<% if blob.representable? %>
<%= image_tag rails_representation_url(blob.representation(resize_to_limit: [600, 400])) %>
<% if caption = blob.try(:caption) %>
<figcaption class="attachment__caption text-center">
<%= caption %>
</figcaption>
<% end %>
<% end %>
</figure>
</td>
</Tr>
</table>发布于 2019-12-09 11:34:47
我发现问题与Action文本有关,在呈现之前使用内部方法对字符串进行清理。
我在初始化器中覆盖允许的属性和标记:
ActionText::ContentHelper.allowed_attributes.add 'style'
ActionText::ContentHelper.allowed_attributes.add 'controls'
ActionText::ContentHelper.allowed_tags.add 'video'
ActionText::ContentHelper.allowed_tags.add 'source'发布于 2019-12-09 10:00:05
在我的例子中,当我在link_to中向_blob.html.erb助手添加一个自定义属性(data-)时,它没有包含在呈现的链接标记中。
<% if blob.representable? %>
<%= link_to image_tag(blob.representation(resize_to_limit:
local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]),
class: 'rounded'), rails_blob_path(blob), { 'data-fancybox': 'gallery' } %>
<% end %>发布于 2019-12-10 21:44:44
我想知道如何在action_name文件中获取_blob.html.erb。因为我想显示或关闭链接到图像,根据动作名称如,show,edit。
https://stackoverflow.com/questions/59019537
复制相似问题