Ignore Front Matter
cseelus opened this issue · 8 comments
Static site generators like Bridgetown or Middleman, usually utilize some kinds of Front Matter, like
---
layout: post
title: Blogging Like a Hacker
---
Unfortunately erb-format
will convert it to this, which doesn't work anymore:
--- layout: post title: Blogging Like a Hacker ---
Using a hash based syntax almost works …
---<%
{
layout: :post,
title: 'Blogging Like a Hacker'
}
%>---
but will also get destroyed upon formating:
---<% {
layout: :post,
title: 'Blogging Like a Hacker'
} %>
---
Is there any known workaround for this problem, like the # rubocop:disable all
comment, which can be added to enclose lines that should be ignored? Would be happy to add this info to the README, if requested.
It looks like all lines of the front matter still get merged into one, so for example this test file …
---
layout: default
---
<h1 class="text-4xl mb-12"><%= resource.data.title %></h1>
<div class="mx-auto lg:mx-48 xl:mx-72 2xl:mx-96">
<%= yield %>
</div>
… will be formatted correctly, except for the front matter:
Maybe you tried with the installed version or one from master? Seems to be working here:
⤑ pbpaste | erb-format --stdin
---
layout: default
---
<h1 class="text-4xl mb-12"><%= resource.data.title %></h1>
<div class="mx-auto lg:mx-48 xl:mx-72 2xl:mx-96">
<%= yield %>
</div>
Your new changes from elia/front-matter
seem to work great now, tested a bunch of files.
A improvement would be, to keep a blank line between the front matter and the actual eruby stuff, like in this or that example.
Before:
---
layout: page
title: About
---
<p>This is the basic Bridgetown (BT) site template. You can find out more info about customizing your Bridgetown site, as well as basic Bridgetown usage documentation at [bridgetownrb.com](https://bridgetownrb.com/)</p>
After:
$ erb-format src/about.erb --no-write
---
layout: page
title: About
---
<p>This is the basic Bridgetown (BT) site template. You can find out more info
about customizing your Bridgetown site, as well as basic Bridgetown usage
documentation at [bridgetownrb.com](https://bridgetownrb.com/)</p>
One other thing, since I couldn't find anything in the docs: The max line length can only be set indirectly via RuboCop::Cop::Layout::LineLength#max
?
One other thing, since I couldn't find anything in the docs: The max line length can only be set indirectly via
RuboCop::Cop::Layout::LineLength#max
?
Does #13 solve?
Pushed an update that will add an extra newline, good call 👍