Skip to content

Instantly share code, notes, and snippets.

@evan-007
Last active January 1, 2016 21:49
Show Gist options
  • Save evan-007/8205699 to your computer and use it in GitHub Desktop.
Save evan-007/8205699 to your computer and use it in GitHub Desktop.
@username to links
<div class="clearfix top-space small"></div>
<div class="row">
<%= render :partial => 'shared/left_nav' %>
<div class="panel panel-default col-md-8 text-left">
<div class="pull-left">
<h4>Twets</h4>
</div>
<div class="clearfix"></div>
<hr />
<ol class="list-unstyled">
<% @twets.each do |twet| -%>
<li>
<%= content_tag :strong, twet.user.name, :class => 'pull-left text-middle' %>
<%= content_tag :small, "@"+twet.user.username, :class => 'text-muted pad-10 text-middle' %>
<%= content_tag :small, twet.created_at.strftime("%b %-d"), :class => 'text-muted text-middle pull-right' %>
<div class="clearfix"></div>
<%= content_tag :p, twet.content.gsub(/@(?<username>(\w+))/,'<a href="'+'/user/\k<username>'+'">@\k<username></a>').html_safe%>
</li>
<li><hr></li>
<% end -%>
</ol>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment