Class: Stencil::Each
- Defined in:
- lib/stencil/directives/base.rb
Instance Method Summary collapse
- #inspect_args ⇒ Object
- #intercept(directive) ⇒ Object
- #render(state) ⇒ Object
-
#setup_parameters(string) ⇒ Object
XXX what if @list doesn’t point to an array?.
Methods inherited from Block
#add, #ended, #initialize, #inspect, #parsed
Methods inherited from Directive
#checked_render, create, #initialize, #inspect, #interpret, #parsed, #postrender, #pre_end, #prerender, register, #render_end
Constructor Details
This class inherits a constructor from Stencil::Block
Instance Method Details
#inspect_args ⇒ Object
228 229 230 |
# File 'lib/stencil/directives/base.rb', line 228 def inspect_args "#@path => #@named_context" end |
#intercept(directive) ⇒ Object
223 224 225 226 |
# File 'lib/stencil/directives/base.rb', line 223 def intercept(directive) @apply << directive nil end |
#render(state) ⇒ Object
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/stencil/directives/base.rb', line 232 def render(state) data = state.data list = data.access(@path) data.push_context(@path, @named_context) data.push_context(@path) result = (0...list.length).map do |index| data.push_context("##{index}", @named_context) data.push_context("##{index}") res = super data.pop_context(@named_context) data.pop_context res end.flatten.compact data.pop_context(@named_context) data.pop_context result end |
#setup_parameters(string) ⇒ Object
XXX what if @list doesn’t point to an array?
219 220 221 |
# File 'lib/stencil/directives/base.rb', line 219 def setup_parameters(string) @path, @named_context = string.split(" ", 2) end |