4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/bard/attachment_field/field.rb', line 4
def render &block
options = @options.transform_keys { _1.to_s.dasherize }.reverse_merge({
"directupload" => "/rails/active_storage/direct_uploads",
"preview" => true,
})
add_default_name_and_id(options)
content = if block
@template_object.capture(options, &block)
else
Array(object.try(@method_name)).map do |attachment|
content_tag("attachment-file", nil, {
name: options["name"],
src: blob_path(attachment),
filename: attachment.filename,
value: attachment.signed_id,
preview: options["preview"],
})
end.join("\n").html_safe
end
content_tag("input-attachment", content, options)
end
|