Module: Jekyll::Convertible
- Defined in:
- lib/jekyll-i18n.rb
Instance Method Summary collapse
- #_read_yaml ⇒ Object
- #_render_liquid ⇒ Object
-
#read_yaml(base, name) ⇒ Object
Enhances the original method to extract the language from the extension.
- #render_liquid(content, payload, info) ⇒ Object
Instance Method Details
#_read_yaml ⇒ Object
41 |
# File 'lib/jekyll-i18n.rb', line 41 alias_method :_read_yaml, :read_yaml |
#_render_liquid ⇒ Object
67 |
# File 'lib/jekyll-i18n.rb', line 67 alias_method :_render_liquid, :render_liquid |
#read_yaml(base, name) ⇒ Object
Enhances the original method to extract the language from the extension. Then adds it as a tag
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/jekyll-i18n.rb', line 45 def read_yaml(base, name) rv = _read_yaml(base, name) # Infer language from first dot in filename. lang = (name.split '.')[1] if lang == 'mul' or I18n.available_locales.include? lang.intern data['lang'] = lang else # Default language is undefined. # If we are procesing a layout, we don't set a language/ # This is so when we do render_liquid, we don't override the page's lang. data['lang'] = 'und' if not self.is_a? Jekyll::Layout end # Add the language as a tag. data['tags'] ||= [] data['tags'] << data['lang'] rv end |
#render_liquid(content, payload, info) ⇒ Object
69 70 71 72 |
# File 'lib/jekyll-i18n.rb', line 69 def render_liquid(content, payload, info) info[:registers][:page]['lang'] = data['lang'] _render_liquid(content, payload, info) end |