Class: ComfortableMexicanSofa::Content::Tag::File
- Inherits:
-
Fragment
- Object
- ComfortableMexicanSofa::Content::Tag
- Fragment
- ComfortableMexicanSofa::Content::Tag::File
- Includes:
- Mixins::FileContent
- Defined in:
- lib/comfortable_mexican_sofa/content/tags/file.rb
Overview
File tag allows attaching of file to the page. This controls how files are uploaded and then displayed on the page. Example tag:
{{ cms:file identifier, as: link, label: "My File" }}
‘as` - url (default) | link | image - render out link or image tag `label` - attach label attribute to link or image tag `resize` - imagemagic option. For example: “100x50>” `gravity` - imagemagic option. For example: “center” `crop` - imagemagic option. For example: “100x50+0+0” `class` - any html classes that you want on the result link or image tag. For example “class1 class2”
Direct Known Subclasses
Instance Attribute Summary collapse
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#variant_attrs ⇒ Object
readonly
Returns the value of attribute variant_attrs.
Attributes inherited from Fragment
#identifier, #namespace, #options, #renderable
Attributes inherited from ComfortableMexicanSofa::Content::Tag
Instance Method Summary collapse
- #form_field(object_name, view, index) {|view.safe_join([input, attachments_partial], "")| ... } ⇒ Object
-
#initialize(context:, params: [], source: nil) ⇒ File
constructor
A new instance of File.
Methods included from Mixins::FileContent
Methods inherited from Fragment
#content, #form_field_id, #fragment, #render
Methods inherited from ComfortableMexicanSofa::Content::Tag
#allow_erb?, #content, #nodes, #render
Constructor Details
#initialize(context:, params: [], source: nil) ⇒ File
Returns a new instance of File.
27 28 29 30 31 32 33 |
# File 'lib/comfortable_mexican_sofa/content/tags/file.rb', line 27 def initialize(context:, params: [], source: nil) super @as = ["as"] || "url" @label = ["label"] @class = ["class"] @variant_attrs = .slice("resize", "gravity", "crop") end |
Instance Attribute Details
#as ⇒ Object (readonly)
Returns the value of attribute as.
21 22 23 |
# File 'lib/comfortable_mexican_sofa/content/tags/file.rb', line 21 def as @as end |
#variant_attrs ⇒ Object (readonly)
Returns the value of attribute variant_attrs.
24 25 26 |
# File 'lib/comfortable_mexican_sofa/content/tags/file.rb', line 24 def variant_attrs @variant_attrs end |
Instance Method Details
#form_field(object_name, view, index) {|view.safe_join([input, attachments_partial], "")| ... } ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/comfortable_mexican_sofa/content/tags/file.rb', line 35 def form_field(object_name, view, index) name = "#{object_name}[fragments_attributes][#{index}][files]" input = view.send(:file_field_tag, name, id: form_field_id, class: "form-control") = if fragment. view.render( partial: "comfy/admin/cms/fragments/form_fragment_attachments", locals: { object_name: object_name, index: index, attachments: fragment., fragment_id: identifier, multiple: false } ) end yield view.safe_join([input, ], "") end |