Module: Lit::FrontendHelper
- Includes:
- ActionView::Helpers::TranslationHelper, TranslationKeyWrapper
- Defined in:
- app/helpers/lit/frontend_helper.rb
Defined Under Namespace
Modules: TranslationKeyWrapper
Instance Method Summary
collapse
#t, #translate
Instance Method Details
#get_translateable_span(key, localization, alternative_text: nil) ⇒ Object
63
64
65
66
67
68
69
|
# File 'app/helpers/lit/frontend_helper.rb', line 63
def get_translateable_span(key, localization, alternative_text: nil)
content_tag :span,
class: 'lit-key-generic',
data: { key: key, locale: I18n.locale } do
localization.blank? ? alternative_text : localization
end
end
|
#javascript_lit_tag ⇒ Object
21
22
23
|
# File 'app/helpers/lit/frontend_helper.rb', line 21
def javascript_lit_tag
javascript_include_tag 'lit/lit_frontend'
end
|
#lit_authorized? ⇒ Boolean
55
56
57
58
59
60
61
|
# File 'app/helpers/lit/frontend_helper.rb', line 55
def lit_authorized?
if Lit.authentication_verification.present?
send(Lit.authentication_verification)
else
true
end
end
|
#lit_frontend_assets ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/helpers/lit/frontend_helper.rb', line 29
def lit_frontend_assets
return unless lit_authorized?
meta = content_tag :meta,
'',
value: lit.find_localization_localization_keys_path,
name: 'lit-url-base'
safe_join([javascript_lit_tag, stylesheet_lit_tag, meta])
end
|
#lit_translations_info ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/helpers/lit/frontend_helper.rb', line 38
def lit_translations_info
return if Thread.current[:lit_request_keys].nil?
return unless lit_authorized?
content_tag :div, class: 'lit-translations-info collapsed' do
concat content_tag :span, 'Show translations', class: 'lit-open-button'
concat content_tag :span, 'X', class: 'lit-close-button'
concat(content_tag(:ul, class: 'lit-translations-list') do
Lit.init.cache.request_keys.each do |k, v|
concat(content_tag(:li) do
concat content_tag :code, "#{k}:"
concat get_translateable_span(k, v, alternative_text: '[empty]')
end)
end
end)
end
end
|
#stylesheet_lit_tag ⇒ Object
25
26
27
|
# File 'app/helpers/lit/frontend_helper.rb', line 25
def stylesheet_lit_tag
stylesheet_link_tag 'lit/lit_frontend'
end
|