Module: Breeze::ViewHelper
Class Method Summary
collapse
Instance Method Summary
collapse
#aspect_ratio, #card_field_name, #last_change_class, #last_change_digit, #last_change_text, #updated_by
#markdown, #markdown_image, #prose_classes, #renderer, #rows
#background_option, #column_option, #date_precision, #height_option, #item_align_option, #margin_option, #options, #order_option, #prose_option, #shade_option, #slider_columns_option, #text_align_option, #text_color_option, #text_columns_option
Class Method Details
.last_blog ⇒ Object
just for tailwind bg-cyan-200
61
62
63
64
65
|
# File 'app/helpers/breeze/view_helper.rb', line 61
def self.last_blog
blog = Page.find_by_type(:blog)
return nil unless blog
blog.sections.last
end
|
Instance Method Details
#bg(section, clazz = "") ⇒ Object
background image as inline style
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/helpers/breeze/view_helper.rb', line 15
def bg(section , clazz = "")
return {class: clazz} if section.image.blank?
img = asset_url( section.image.asset_name )
style = "background-image: url('#{img}');"
if(section.option("fixed") == "on")
clazz += " bg-fixed"
end
if(align = section.option("image_align"))
clazz += " bg-#{align}"
end
{class: clazz , style: style}
end
|
37
38
39
|
# File 'app/helpers/breeze/view_helper.rb', line 37
def button_classes
"inline-block rounded-lg px-3 py-2 text-base font-medium border border-gray-500 hover:border-black"
end
|
#current_lang ⇒ Object
5
6
7
|
# File 'app/helpers/breeze/view_helper.rb', line 5
def current_lang
params[:lang]
end
|
#get_button_text(element) ⇒ Object
41
42
43
44
45
|
# File 'app/helpers/breeze/view_helper.rb', line 41
def get_button_text(element)
text = element.option("button_text")
return text unless text.include?("_")
I18n.t( text )
end
|
71
72
73
74
75
76
77
78
|
# File 'app/helpers/breeze/view_helper.rb', line 71
def
return "" unless blog_section = last_blog
blog = blog_section.page
= blog.sections.collect{|s| "- " + s.}
.shift
return "" if .empty?
markdown .join("\n")
end
|
#image_for(element, classes = "") ⇒ Object
works for with sections and cards that respond to .image
31
32
33
34
35
|
# File 'app/helpers/breeze/view_helper.rb', line 31
def image_for(element , classes = "")
return "" if element.image.blank?
image = element.image
image_tag(image.asset_name , alt: image.name , class: classes )
end
|
#last_blog ⇒ Object
67
68
69
|
# File 'app/helpers/breeze/view_helper.rb', line 67
def last_blog
ViewHelper.last_blog
end
|
#render_section(section) ⇒ Object
9
10
11
12
|
# File 'app/helpers/breeze/view_helper.rb', line 9
def render_section(section)
template = "breeze/view/" + section.template
render( template , section: section)
end
|
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'app/helpers/breeze/view_helper.rb', line 47
def view_button(element , = "")
return "" unless element.has_option?("button_link")
["<button class='#{button_classes} ",
,
"'>" ,
"<a href='" ,
element.option("button_link") ,
"'>" ,
get_button_text(element) ,
"</a>",
" </button>"].join.html_safe
end
|