| Class | TemplatePage::Context |
| In: |
template.rb
doc-tmp/rdoc/template.rb |
| Parent: | Object |
A context holds a stack of key/value pairs (like a symbol table). When asked to resolve a key, it first searches the top of the stack, then the next level, and so on until it finds a match (or runs out of entries)
Find a scalar value, throwing an exception if not found. This method is used when substituting the %xxx% constructs
# File template.rb, line 62
62: def find_scalar(key)
63: @stack.reverse_each do |level|
64: if val = level[key]
65: return val unless val.kind_of? Array
66: end
67: end
68: raise "Template error: can't find variable '#{key}'"
69: end
Find a scalar value, throwing an exception if not found. This method is used when substituting the %xxx% constructs
# File doc-tmp/rdoc/template.rb, line 62
62: def find_scalar(key)
63: @stack.reverse_each do |level|
64: if val = level[key]
65: return val unless val.kind_of? Array
66: end
67: end
68: raise "Template error: can't find variable '#{key}'"
69: end
Lookup any key in the stack of hashes
# File template.rb, line 73
73: def lookup(key)
74: @stack.reverse_each do |level|
75: val = level[key]
76: return val if val
77: end
78: nil
79: end
Lookup any key in the stack of hashes
# File doc-tmp/rdoc/template.rb, line 73
73: def lookup(key)
74: @stack.reverse_each do |level|
75: val = level[key]
76: return val if val
77: end
78: nil
79: end