Skip to content

Commit 842bec8

Browse files
committed
Use YAML#dump for YAML encoding
1 parent b3e656c commit 842bec8

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

lib/jekyll-compose/file_info.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@ def file_name
1010
end
1111

1212
def content
13-
<<-CONTENT.gsub /^\s+/, ''
14-
---
15-
layout: #{params.layout}
16-
title: #{yaml_clean_title}
17-
---
18-
CONTENT
19-
end
20-
21-
private
13+
front_matter = YAML.dump({
14+
'layout' => params.layout,
15+
'title' => params.title,
16+
})
2217

23-
def yaml_clean_title
24-
if params.title.include? ':'
25-
'"' + params.title + '"'
26-
else
27-
params.title
28-
end
18+
front_matter + "---\n"
2919
end
3020
end

spec/file_info_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '')
2626
---
2727
layout: post
28-
title: "A test: arg parser"
28+
title: 'A test: arg parser'
2929
---
3030
CONTENT
3131
}

0 commit comments

Comments
 (0)