module Locomotive module Liquid module Tags # Display the links to change the locale of the current page # # Usage: # # {% locale_switcher %} =>
# # {% 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 # class LocaleSwitcher < ::Liquid::Tag Syntax = /(#{::Liquid::Expression}+)?/ def initialize(tag_name, markup, tokens, context) @options = { :label => 'iso', :sep => ' | ' } if markup =~ Syntax markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/"|'/, '') } @options[:exclude] = Regexp.new(@options[:exclude]) if @options[:exclude] else raise ::Liquid::SyntaxError.new("Syntax Error in 'locale_switcher' - Valid syntax: locale_switcher