File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed
Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ def file_name
99 "#{ name } .#{ params . type } "
1010 end
1111
12- def content
12+ def content ( custom_front_matter = { } )
1313 front_matter = YAML . dump ( {
1414 "layout" => params . layout ,
1515 "title" => params . title ,
16- } )
16+ } . merge ( custom_front_matter ) )
1717
1818 front_matter + "---\n "
1919 end
Original file line number Diff line number Diff line change @@ -54,6 +54,14 @@ def file_name
5454 def _date_stamp
5555 @params . date . strftime "%Y-%m-%d"
5656 end
57+
58+ def _time_stamp
59+ @params . date . strftime ( "%Y-%m-%d %H:%M %z" )
60+ end
61+
62+ def content ( custom_front_matter = { } )
63+ super ( { "date" => _time_stamp } . merge ( custom_front_matter ) )
64+ end
5765 end
5866 end
5967 end
Original file line number Diff line number Diff line change 4545 expect ( file_info . content ) . to eq ( expected_result )
4646 end
4747 end
48+
49+ context "with custom values" do
50+ let ( :expected_result ) do
51+ <<-CONTENT . gsub ( %r!^\s +! , "" )
52+ ---
53+ layout: post
54+ title: A test
55+ foo: bar
56+ ---
57+ CONTENT
58+ end
59+
60+ let ( :parsed_args ) do
61+ Jekyll ::Compose ::ArgParser . new (
62+ [ "A test arg parser" ] ,
63+ { }
64+ )
65+ end
66+
67+ it "does not wrap the title in quotes" do
68+ file_info = described_class . new parsed_args
69+ expect ( file_info . content ( "title" => "A test" , "foo" => "bar" ) ) . to eq ( expected_result )
70+ end
71+ end
4872 end
4973end
Original file line number Diff line number Diff line change 33 let ( :args ) { [ name ] }
44 let ( :posts_dir ) { Pathname . new source_dir ( "_posts" ) }
55 let ( :datestamp ) { Time . now . strftime ( "%Y-%m-%d" ) }
6+ let ( :timestamp ) { Time . now . strftime ( "%Y-%m-%d %H:%M %z" ) }
67 let ( :filename ) { "#{ datestamp } -a-test-post.md" }
78 let ( :path ) { posts_dir . join ( filename ) }
89
3031 expect ( path ) . not_to exist
3132 capture_stdout { described_class . process ( args , { "date" => "2012-3-4" } ) }
3233 expect ( path ) . to exist
34+ expect ( File . read ( path ) ) . to match ( %r!date: 2012-03-04 00:00 \+ 0000! )
3335 end
3436
3537 it "creates the post with a specified extension" do
You can’t perform that action at this time.
0 commit comments