Class: Curlybars::Node::Template
- Inherits:
-
Struct
- Object
- Struct
- Curlybars::Node::Template
- Defined in:
- lib/curlybars/node/template.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#position ⇒ Object
Returns the value of attribute position.
Instance Method Summary collapse
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items
3 4 5 |
# File 'lib/curlybars/node/template.rb', line 3 def items @items end |
#position ⇒ Object
Returns the value of attribute position
3 4 5 |
# File 'lib/curlybars/node/template.rb', line 3 def position @position end |
Instance Method Details
#cache_key ⇒ Object
27 28 29 |
# File 'lib/curlybars/node/template.rb', line 27 def cache_key Digest::MD5.hexdigest(items.map(&:cache_key).join("/")) end |
#compile ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/curlybars/node/template.rb', line 4 def compile compiled_items = items.map(&:compile).join("\n") # NOTE: the following is a heredoc string, representing the ruby code fragment # outputted by this node. <<-RUBY ::Module.new do def self.exec(contexts, rendering, variables, buffer) unless contexts.length < ::Curlybars.configuration.nesting_limit message = "Nesting too deep" position = rendering.position(#{position.line_number}, #{position.line_offset}) raise ::Curlybars::Error::Render.new('nesting_too_deep', message, position) end #{compiled_items} end end.exec(contexts, rendering, variables, buffer) RUBY end |
#validate(branches) ⇒ Object
23 24 25 |
# File 'lib/curlybars/node/template.rb', line 23 def validate(branches) items.map { |item| item.validate(branches) } end |