Class: ComfortableMexicanSofa::Tag::Upload
Constant Summary
TOKENIZER_REGEX
Instance Attribute Summary
#label, #page, #params, #parent
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.regex_tag_signature(label = nil) ⇒ Object
4
5
6
7
|
# File 'lib/comfortable_mexican_sofa/tags/upload.rb', line 4
def self.regex_tag_signature(label = nil)
label ||= /[\w\-\.]+/
/\{\{\s*cms:upload:(#{label}):?(.*?)\s*\}\}/
end
|
Instance Method Details
#content ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/comfortable_mexican_sofa/tags/upload.rb', line 9
def content
return unless upload
format = params[0]
text = params[1] || label
case format
when 'link'
"<a href='#{upload.file.url}' target='_blank'>#{text}</a>"
when 'image'
"<img src='#{upload.file.url}' alt='#{text}' />"
else
upload.file.url
end
end
|