Created
January 12, 2017 19:23
-
-
Save benphelps/156012f86f7f0c8b9fd6f9ea8e7e93e7 to your computer and use it in GitHub Desktop.
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
def sub_heading(content = nil) | |
@sub_headings ||= [] | |
if content | |
@sub_headings.push content | |
elsif block_given? | |
@sub_headings.each do |sub_heading| | |
yield sub_heading | |
end | |
else | |
Enumerator.new do |y| | |
@sub_headings.each do |sub_heading| | |
y << sub_heading | |
end | |
end | |
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
<!-- Add links to the sub heading --> | |
<% sub_heading link_to('A Link', some_path) %> | |
<% sub_heading link_to('Another One', some_path) %> | |
<!-- Use links in a block of HTML --> | |
<% sub_heading do |heading| %> | |
<small><%= heading %></small> | |
<% end %> | |
<!-- Use links in other ways too --> | |
<% sub_heading.collect { |l| strip_tags(l) }.join(' - ') %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment