Class: Liquid::Template::TagRegistry

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/liquid/template.rb

Instance Method Summary collapse

Constructor Details

#initializeTagRegistry

Returns a new instance of TagRegistry.



24
25
26
27
# File 'lib/liquid/template.rb', line 24

def initialize
  @tags = {}
  @cache = {}
end

Instance Method Details

#[](tag_name) ⇒ Object



29
30
31
32
33
34
# File 'lib/liquid/template.rb', line 29

def [](tag_name)
  return nil unless @tags.key?(tag_name)
  return @cache[tag_name] if Liquid.cache_classes

  lookup_class(@tags[tag_name]).tap { |o| @cache[tag_name] = o }
end

#[]=(tag_name, klass) ⇒ Object



36
37
38
39
# File 'lib/liquid/template.rb', line 36

def []=(tag_name, klass)
  @tags[tag_name]  = klass.name
  @cache[tag_name] = klass
end

#delete(tag_name) ⇒ Object



41
42
43
44
# File 'lib/liquid/template.rb', line 41

def delete(tag_name)
  @tags.delete(tag_name)
  @cache.delete(tag_name)
end

#each(&block) ⇒ Object



46
47
48
# File 'lib/liquid/template.rb', line 46

def each(&block)
  @tags.each(&block)
end