Skip to content

Instantly share code, notes, and snippets.

@gonzedge
Created January 4, 2012 04:45
Show Gist options
  • Save gonzedge/1558550 to your computer and use it in GitHub Desktop.
Save gonzedge/1558550 to your computer and use it in GitHub Desktop.
Writing elegant HTML with HAML
<div id="single_post">
<h2 class="post_title"><%= link_to post.title, post %></h2>
<div class="post_content">
<div class="post_date">
Posted on <%= post.date.strftime '%e %B %Y' %>
</div>
<div class="posted_by">
By: <%= post.author %>
</div>
<div class="comments_number">
<%= post.comment_count %>
</div>
<% if summary %>
<%= post.summary_html %>
<%= link_to post do %>
Continue Reading &raquo;
<% end %>
<% else %>
<%= post.content_html %>
<% end %>
<ul class="post_tags">
<% post.tags.each do |tag| %>
<li>
<a href="<%= tag_path(tag) %>">
<%= tag.name %>
</a>
</li>
</ul>
</div>
</div>
#single_post
%h2.post_title= link_to post.title, post
.post_content
.post_date
Posted on #{post.date.strftime '%e %B %Y'}
.posted_by
By: #{post.author}
.comments_number= post.comment_count
- if summary
= post.summary_html
= link_to post do
Continue Reading &raquo;
- else
= post.content_html
%ul.post_tags
- post.tags.each do |tag|
%li
%a{href: "/blog/tag/#{tag.name}"}= tag.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment