I am trying to create a blog in Rails and using Markdown/Jekyll Converter, but getting an error when my markdown files contain references to variables used in my "parse file method"
The Parse Method does the following:
def parse_file
@markdown = Tilt::ErubisTemplate.new do
fdata = file_data
if fdata =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
logger.debug 'parsing yaml'
@data = SafeYAML.load($1)
logger.debug 'parsing complete'
logger.debug @data
logger.debug $POSTMATCH
$POSTMATCH
else
fdata
end
logger.debug self
end.render(scope, post: self)
end
My markdown files may have code like the following:
Show will just display the single Blog Post the user clicks on from the index to continue reading and these details:
```ruby
<% @posts.each do |post| %>
<article>
<div class="summary">
<header>
<h1>
<%= link_to post.title, post.path%>
</h1>
</header>
<%= render partial: "meta", locals: { post: post } %>
<p><%= post.excerpt %></p>
<p><%= link_to "Continue reading →", post.path %></p>
</div>
</article>
<% end %>
```
The error is Receive when I got to here: /blog
ERROR: undefined method `each' for nil:NilClass And it highlights
end.render(scope, post: self)
end
Any ideas? It looks like when its parsing @post, it throws an error as if it doesn't know how to parse this data, but most people must deal with markdown when the code blocks have variables, don't they?