Skip to content

Instantly share code, notes, and snippets.

@tyre
Last active August 29, 2015 14:22
Show Gist options
  • Save tyre/34c3aa0c0b583f885538 to your computer and use it in GitHub Desktop.
Save tyre/34c3aa0c0b583f885538 to your computer and use it in GitHub Desktop.
def render_with_spacer([], _template, _var_key, _spacer_template) do
nil
end
def render_with_spacer([h], template, var_key, _spacer_template) do
render template, var_key => h
end
def render_with_spacer([h|rest], template, var_key, spacer_template) do
render template, var_key => h
render spacer_template
render_with_spacer(rest, template, var_key, spacer_template)
end
## Usage
render_with_spacer(@products, "product.html", :product, "spacer.html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment