Class: Jekyll::LocalizeLink
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::LocalizeLink
- Defined in:
- lib/jekyll/multiple/languages/plugin.rb
Instance Method Summary collapse
-
#initialize(tag_name, key, tokens) ⇒ LocalizeLink
constructor
A new instance of LocalizeLink.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, key, tokens) ⇒ LocalizeLink
Returns a new instance of LocalizeLink.
149 150 151 152 |
# File 'lib/jekyll/multiple/languages/plugin.rb', line 149 def initialize(tag_name, key, tokens) super @key = key end |
Instance Method Details
#render(context) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/jekyll/multiple/languages/plugin.rb', line 154 def render(context) if "#{context[@key]}" != "" #Check for page variable key = "#{context[@key]}" else key = @key end key = key.split namespace = key[0] lang = key[1] || context.registers[:site].config['lang'] default_lang = context.registers[:site].config['default_lang'] baseurl = context.registers[:site].baseurl pages = context.registers[:site].pages url = ""; if default_lang != lang baseurl = baseurl + "/" + lang end for p in pages unless p['namespace'].nil? page_namespace = p['namespace'] if namespace == page_namespace permalink = p['permalink_'+lang] || p['permalink'] url = baseurl + permalink end end end url end |