Class: Liquid::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/dm_core/liquid_extensions.rb

Class Method Summary collapse

Class Method Details

.register_tag(name, klass) ⇒ Object




10
11
12
# File 'lib/dm_core/liquid_extensions.rb', line 10

def register_tag(name, klass)
  register_tag_namespace(name, klass)
end

.register_tag_namespace(name, klass, namespace = 'system_tags') ⇒ Object

Store tags in a namespace, usually a theme name. This is so we can register many different tags for each theme and keep them seperate.




17
18
19
# File 'lib/dm_core/liquid_extensions.rb', line 17

def register_tag_namespace(name, klass, namespace = 'system_tags')
  tags_namespaced(namespace)[name.to_s] = klass
end

.tagsObject

return the list of tags that are available. Tags available at any instance is the global tags, the current theme’s tags, and the parent theme’s tags.




24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dm_core/liquid_extensions.rb', line 24

def tags
  if Account.current.nil?
    tags_namespaced('system_tags').merge(@tags)
  else
    t = tags_namespaced('system_tags').merge(@tags).merge(tags_namespaced(Account.current.current_theme))
    
    #--- if parent theme, reverse_merge tags - they should not override current theme tags
    t.reverse_merge!(tags_namespaced(Account.current.parent_theme)) if Account.current.parent_theme
    return t
  end
end

.tags_namespaced(namespace) ⇒ Object




37
38
39
40
# File 'lib/dm_core/liquid_extensions.rb', line 37

def tags_namespaced(namespace)
  @tags_namespaced            ||= {}
  @tags_namespaced[namespace] ||= {}
end