Class: ComfortableMexicanSofa::Tag::File
- Inherits:
-
Object
- Object
- ComfortableMexicanSofa::Tag::File
- Includes:
- ComfortableMexicanSofa::Tag
- Defined in:
- lib/comfortable_mexican_sofa/tags/file.rb
Constant Summary
Constants included from ComfortableMexicanSofa::Tag
IDENTIFIER_REGEX, TOKENIZER_REGEX
Instance Attribute Summary
Attributes included from ComfortableMexicanSofa::Tag
#blockable, #identifier, #namespace, #params, #parent
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
-
#file ⇒ Object
Initializing Comfy::Cms::File object.
Class Method Details
.regex_tag_signature(identifier = nil) ⇒ Object
4 5 6 7 |
# File 'lib/comfortable_mexican_sofa/tags/file.rb', line 4 def self.regex_tag_signature(identifier = nil) identifier ||= IDENTIFIER_REGEX /\{\{\s*cms:file:(#{identifier}):?(.*?)\s*\}\}/ end |
Instance Method Details
#content ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/comfortable_mexican_sofa/tags/file.rb', line 14 def content return unless file format = params[0] text = params[1] || identifier case format when 'link' "<a href='#{file.file.url}' target='_blank'>#{text}</a>" when 'image' "<img src='#{file.file.url}' alt='#{text}' />" else file.file.url end end |
#file ⇒ Object
Initializing Comfy::Cms::File object
10 11 12 |
# File 'lib/comfortable_mexican_sofa/tags/file.rb', line 10 def file blockable.site.files.detect{|f| f.file_file_name == self.identifier.to_s} end |