Created
December 9, 2015 21:11
-
-
Save chrisvarao/5c39f3f9042177bbf0d1 to your computer and use it in GitHub Desktop.
Custom erb tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hey dave, check out my custom tag. Isn't it cool? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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