Topic: Turning blocks into arrays
Simple problem I am trying to solve. I am often given a list of links which are conditionally output and concatenated with pipe characters.
Example:
Link 1 | Link 2 | Link 3
My aim is to write a method which would allow me to achieve this as follows:
- split_links do
- if foo?
= link_to "foo", "#foo"
- if bar?
= link_to "bar", "#bar"
= link_to "baz", "#baz"# only foo? is true
=> Foo | Baz
I know I can capture a block within a helper, but i have no idea how to append each argument to an array that I can manipulate with join(' | ')
Any ideas?
Last edited by pimpmaster (2011-06-23 08:06:13)