Skip to content

Commit

Permalink
Use YAML#dump for YAML encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
djds23 committed Mar 15, 2016
1 parent b3e656c commit 842bec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
20 changes: 5 additions & 15 deletions lib/jekyll-compose/file_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ def file_name
end

def content
<<-CONTENT.gsub /^\s+/, ''
---
layout: #{params.layout}
title: #{yaml_clean_title}
---
CONTENT
end

private
front_matter = YAML.dump({
'layout' => params.layout,
'title' => params.title,
})

def yaml_clean_title
if params.title.include? ':'
'"' + params.title + '"'
else
params.title
end
front_matter + "---\n"
end
end
2 changes: 1 addition & 1 deletion spec/file_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '')
---
layout: post
title: "A test: arg parser"
title: 'A test: arg parser'
---
CONTENT
}
Expand Down

0 comments on commit 842bec8

Please sign in to comment.