Middleman-Blog: How Do I use the same partial in index loop and article site?

Hello,

new to Middleman, at the moment I try to build a blog with Middleman and I have to a problem to use the same partial for the loop in index.html.erb and my article_layout.html.erb

index.html.erb:

  <%= partial(:article, :locals => { :article => article} ) %>
<% end %>

article_layout.html.erb

 <%= partial(:article, :locals => { :article => current_resouce.data} ) %>
<% end %>

_article.html.erb

  <h2><%= link_to article.title, article %></h2>
  <time datetime="<%= article.date.strftime('%Y-%m-%d') %>"><%= article.date.strftime('%d.%m.%Y') %></time>
  <%= article.body %>
</article>

The index site works. But if I call an article on it’s own URL I get a bad argument (expected URI object or URI string) error.

Basically I just want to use the same HTML for the index site and the article without repeating myself. How can I achieve this?

Why is it not <%= partial(:article, :locals => { :article => current_resouce} ) %> (without .data) in the article_layout.html.erb ?

1 Like

Now it works! Thanks a lot!