Class: Locomotive::Steam::Liquid::Tags::LocaleSwitcher
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Locomotive::Steam::Liquid::Tags::LocaleSwitcher
- Includes:
- Concerns::Attributes, Concerns::I18nPage
- Defined in:
- lib/locomotive/steam/liquid/tags/locale_switcher.rb
Overview
Display the links to change the locale of the current page
Usage:
locale_switcher % => <div id=“locale-switcher”><a href=“/features” class=“current en”>Features</a><a href=“/fr/fonctionnalites” class=“fr”>Fonctionnalités</a></div>
{% locale_switcher label: locale, sep: ‘ - ’ }
options:
- label: iso (de, fr, en, ...etc), locale (Deutsch, Français, English, ...etc), title (page title)
- sep: piece of html code separating 2 locales
notes:
- "iso" is the default choice for label
- " | " is the default separating code
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#current_locale ⇒ Object
readonly
Returns the value of attribute current_locale.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#url_builder ⇒ Object
readonly
Returns the value of attribute url_builder.
Attributes included from Concerns::Attributes
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ LocaleSwitcher
constructor
A new instance of LocaleSwitcher.
- #render(context) ⇒ Object
Methods included from Concerns::I18nPage
Constructor Details
#initialize(tag_name, markup, options) ⇒ LocaleSwitcher
Returns a new instance of LocaleSwitcher.
30 31 32 33 34 |
# File 'lib/locomotive/steam/liquid/tags/locale_switcher.rb', line 30 def initialize(tag_name, markup, ) super parse_attributes(markup, label: 'iso', sep: ' | ') end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
28 29 30 |
# File 'lib/locomotive/steam/liquid/tags/locale_switcher.rb', line 28 def attributes @attributes end |
#current_locale ⇒ Object (readonly)
Returns the value of attribute current_locale.
28 29 30 |
# File 'lib/locomotive/steam/liquid/tags/locale_switcher.rb', line 28 def current_locale @current_locale end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
28 29 30 |
# File 'lib/locomotive/steam/liquid/tags/locale_switcher.rb', line 28 def page @page end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
28 29 30 |
# File 'lib/locomotive/steam/liquid/tags/locale_switcher.rb', line 28 def site @site end |
#url_builder ⇒ Object (readonly)
Returns the value of attribute url_builder.
28 29 30 |
# File 'lib/locomotive/steam/liquid/tags/locale_switcher.rb', line 28 def url_builder @url_builder end |
Instance Method Details
#render(context) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/locomotive/steam/liquid/tags/locale_switcher.rb', line 36 def render(context) evaluate_attributes(context) set_vars_from_context(context) %{<div id="locale-switcher">#{build_site_locales}</div>} end |