Module: HeraCms::TagHelper
- Defined in:
- app/helpers/hera_cms/tag_helper.rb
Instance Method Summary collapse
- #hera_admin_navbar ⇒ Object
- #hera_image(identifier, args = {}) ⇒ Object
- #hera_link(identifier, args = {}, &block) ⇒ Object
- #hera_text(identifier, args = {}) ⇒ Object
- #set_classes(args, editable) ⇒ Object
-
#set_editable(editable) ⇒ Object
def hera_form(identifier, args = {}) form = Form.identify(identifier) set_editable(form) unless args == false identifier, send_to, classes, style = form.identifier, form.send_to, form.classes, form.style html_options = { class: classes, style: style, id: identifier, data: { editable_id: form.id, editable_type: form.model_name.route_key, mail: form.send_to} } form_tag(“/contact”, html_options ) do concat hidden_field_tag(“form_id”, form.id) concat text_field_tag(‘name’,“”, placeholder: “Nome”) concat text_field_tag(‘email’,“”, placeholder: “E-mail”) concat text_field_tag(‘phone’,“”, placeholder: “Telefone”) concat text_area_tag(‘message’,“”, placeholder: “Digite sua mensagem aqui”) concat submit_tag(‘Enviar’) end end.
Instance Method Details
#hera_admin_navbar ⇒ Object
4 5 6 |
# File 'app/helpers/hera_cms/tag_helper.rb', line 4 def render 'hera_cms/shared/navbar' end |
#hera_image(identifier, args = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/hera_cms/tag_helper.rb', line 46 def hera_image(identifier, args = {}) image = HeraCms::Image.identify(identifier) identifier, upload, style = image.identifier, image.upload, image.style classes = set_classes(args, image) args[:type] ||= "image" url = HeraCms.active_storage? ? url_for(upload) : image.url = { class: classes, style: style, id: identifier, data: { editable_id: image.id, editable_type: image.model_name.route_key, editable_upload: HeraCms.active_storage? } } if args[:type] == "video" content_tag(:div, video_tag(url, style: "max-width: 100%; max-height: 100%;"), ) else content_tag(:div, image_tag(url, style: "max-width: 100%; max-height: 100%;"), ) end end |
#hera_link(identifier, args = {}, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/hera_cms/tag_helper.rb', line 8 def hera_link(identifier, args = {}, &block) link = HeraCms::Link.identify(identifier) inner_text, style, identifier, path = link.inner_text, link.style, link.identifier, link.path classes = set_classes(args, link) = { class: classes, style: style, id: identifier, data: { editable_id: link.id, editable_type: link.model_name.route_key} } args[:attributes]&.each do |key, value| [key] = value end if block_given? link_to(path, , &block) else link_to(inner_text, path, ) end end |
#hera_text(identifier, args = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/hera_cms/tag_helper.rb', line 31 def hera_text(identifier, args = {}) text = HeraCms::Text.identify(identifier) inner_text, style, identifier = text.inner_text, text.style, text.identifier classes = set_classes(args, text) args[:html_tag] ||= "p" = { class: classes, style: style, id: identifier, data: { editable_id: text.id, editable_type: text.model_name.route_key} } return content_tag(args[:html_tag].to_sym, inner_text, ) end |
#set_classes(args, editable) ⇒ Object
115 116 117 118 119 |
# File 'app/helpers/hera_cms/tag_helper.rb', line 115 def set_classes(args, editable) args[:add_class] ||= "" classes = "#{ args[:class] || editable.classes } #{args[:add_class]}" classes += " hera-editable" unless args[:editable] == false || editable.classes&.include?("hera-editable") || !editable.editable? end |
#set_editable(editable) ⇒ Object
def hera_form(identifier, args = {})
form = Form.identify(identifier)
set_editable(form) unless args[:editable] == false
identifier, send_to, classes, style = form.identifier, form.send_to, form.classes, form.style
= {
class: classes,
style: style,
id: identifier,
data: { editable_id: form.id, editable_type: form.model_name.route_key, mail: form.send_to}
}
form_tag("/contact", ) do
concat hidden_field_tag("form_id", form.id)
concat text_field_tag('name',"", placeholder: "Nome")
concat text_field_tag('email',"", placeholder: "E-mail")
concat text_field_tag('phone',"", placeholder: "Telefone")
concat text_area_tag('message',"", placeholder: "Digite sua mensagem aqui")
concat submit_tag('Enviar')
end
end
111 112 113 |
# File 'app/helpers/hera_cms/tag_helper.rb', line 111 def set_editable(editable) editable.classes += " hera-editable" if editable.editable? && (editable.classes && !editable.classes&.include?("hera-editable")) end |