Class: Gitlab::TemplateParser::AST::Each
- Inherits:
-
Struct
- Object
- Struct
- Gitlab::TemplateParser::AST::Each
- Defined in:
- lib/gitlab/template_parser/ast.rb
Overview
An ‘each` expression.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#collection ⇒ Object
Returns the value of attribute collection.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
111 112 113 |
# File 'lib/gitlab/template_parser/ast.rb', line 111 def body @body end |
#collection ⇒ Object
Returns the value of attribute collection
111 112 113 |
# File 'lib/gitlab/template_parser/ast.rb', line 111 def collection @collection end |
Instance Method Details
#evaluate(state, data) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/gitlab/template_parser/ast.rb', line 112 def evaluate(state, data) values = collection.evaluate(state, data) return '' unless values.respond_to?(:each) # While unlikely to happen, it's possible users attempt to nest many # loops in order to negatively impact the GitLab instance. To make # this more difficult, we limit the number of nested loops a user can # create. state.enter_loop do values.map { |value| body.evaluate(state, value) }.join('') end end |