Module: Lesli::GeneralHelper
- Defined in:
- app/helpers/lesli/general_helper.rb
Instance Method Summary collapse
-
#application_body_class ⇒ Object
return a string with a css class to identify the body example: builder engine-controller action.
-
#language_flag(locale) ⇒ Object
return flag code according to locale code.
-
#language_name(locale) ⇒ Object
return the name of the language.
-
#language_url(locale) ⇒ Object
build a url path to change locales.
-
#lesli_svg(name) ⇒ Object
print a custom icon for lesli.
-
#website_meta_description ⇒ Object
build description using custom data from controller or engine gem description.
-
#website_title ⇒ Object
build the text for the html document title this helper works only for rails pages, for vue apps the title must be handled with JS.
Instance Method Details
#application_body_class ⇒ Object
return a string with a css class to identify the body example: builder engine-controller action
61 62 63 |
# File 'app/helpers/lesli/general_helper.rb', line 61 def application_body_class [lesli_instance_code, controller_path.gsub("/", "-"), action_name].join(" ") end |
#language_flag(locale) ⇒ Object
return flag code according to locale code
42 43 44 45 |
# File 'app/helpers/lesli/general_helper.rb', line 42 def language_flag(locale) locale = "gb" if locale.to_s == "en" locale end |
#language_name(locale) ⇒ Object
return the name of the language
48 49 50 |
# File 'app/helpers/lesli/general_helper.rb', line 48 def language_name(locale) Lesli.config.locales.dig(locale) || "undefined" end |
#language_url(locale) ⇒ Object
build a url path to change locales
37 38 39 |
# File 'app/helpers/lesli/general_helper.rb', line 37 def language_url(locale) "/lesli/language?locale=#{locale}" end |
#lesli_svg(name) ⇒ Object
print a custom icon for lesli
53 54 55 56 57 |
# File 'app/helpers/lesli/general_helper.rb', line 53 def lesli_svg(name) content_tag("svg", width: "64px", height: "64px") do "<use xlink:href='##{name}'></use>".html_safe end end |
#website_meta_description ⇒ Object
build description using custom data from controller or engine gem description
76 77 78 79 80 81 |
# File 'app/helpers/lesli/general_helper.rb', line 76 def # if want to get description from gem you can use: # Gem::Specification.find_by_name(engine_name).description # Gem::Specification.find_by_name(engine_name).summary @application_html_description || "" end |
#website_title ⇒ Object
build the text for the html document title this helper works only for rails pages, for vue apps the title must be handled with JS
67 68 69 70 71 72 73 |
# File 'app/helpers/lesli/general_helper.rb', line 67 def website_title return @application_html_title if @application_html_title title = controller_path.gsub("cloud", "").gsub("_", "") name = @account.dig(:company, :name) "#{title} - #{name}" end |