Class: Liquid::Template::TagRegistry

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

Instance Method Summary collapse

Constructor Details

#initializeTagRegistry

Returns a new instance of TagRegistry.



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

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

Instance Method Details

#[](tag_name) ⇒ Object



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

def [](tag_name)
  return nil unless @tags.has_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



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

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

#delete(tag_name) ⇒ Object



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

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