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. " ::Module.new do\n def self.exec(contexts, rendering, variables, buffer)\n unless contexts.length < ::Curlybars.configuration.nesting_limit\n message = \"Nesting too deep\"\n position = rendering.position(\#{position.line_number}, \#{position.line_offset})\n raise ::Curlybars::Error::Render.new('nesting_too_deep', message, position)\n end\n \#{compiled_items}\n end\n end.exec(contexts, rendering, variables, buffer)\n RUBY\nend\n" |
#validate(branches) ⇒ Object
23 24 25 |
# File 'lib/curlybars/node/template.rb', line 23 def validate(branches) items.map { |item| item.validate(branches) } end |