Skip to content

Instantly share code, notes, and snippets.

@chrisvarao
Created December 9, 2015 21:11
Show Gist options
  • Save chrisvarao/5c39f3f9042177bbf0d1 to your computer and use it in GitHub Desktop.
Save chrisvarao/5c39f3f9042177bbf0d1 to your computer and use it in GitHub Desktop.
Custom erb tags
module ApplicationHelper
def cool_tag(opts={}, &block)
name = opts[:name] || 'guys'
content = capture(&block).strip
"Hey #{name}, check out my #{content} tag. Isn't it cool?"
end
end
Hey dave, check out my custom tag. Isn't it cool?
<%= cool_tag name: 'dave' do %>
custom
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment