class Liquid::Template

Public Class Methods

register_tag(name, klass) click to toggle source
# 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') click to toggle source

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.

# 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
tags() click to toggle source

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.

# 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) click to toggle source
# File lib/dm_core/liquid_extensions.rb, line 37
def tags_namespaced(namespace)
  @tags_namespaced            ||= {}
  @tags_namespaced[namespace] ||= {}
end