File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ class GistTag < Liquid::Tag
55 def render ( context )
66 if tag_contents = determine_arguments ( @markup . strip )
77 gist_id , filename = tag_contents [ 0 ] , tag_contents [ 1 ]
8+ if context . key? ( gist_id )
9+ gist_id = context [ gist_id ]
10+ end
11+ if context . key? ( filename )
12+ filename = context [ filename ]
13+ end
814 gist_script_tag ( gist_id , filename )
915 else
1016 raise ArgumentError . new <<-eos
Original file line number Diff line number Diff line change 4343 expect ( output ) . to match ( /<script src="https:\/ \/ gist.github.com\/ #{ gist } .js\? file=#{ filename } ">\s <\/ script>/ )
4444 end
4545 end
46+
47+ context "with variable gist id" do
48+ let ( :gist ) { "page.gist_id" }
49+ let ( :output ) do
50+ doc . data [ 'gist_id' ] = "1342013"
51+ doc . content = content
52+ doc . output = Jekyll ::Renderer . new ( doc . site , doc ) . run
53+ end
54+
55+ it "produces the correct script tag" do
56+ expect ( output ) . to match ( /<script src="https:\/ \/ gist.github.com\/ #{ doc . data [ 'gist_id' ] } .js">\s <\/ script>/ )
57+ end
58+ end
59+
60+ context "with variable gist id and filename" do
61+ let ( :gist ) { "page.gist_id" }
62+ let ( :filename ) { "page.gist_filename" }
63+ let ( :content ) { "{% gist #{ gist } #{ filename } %}" }
64+ let ( :output ) do
65+ doc . data [ 'gist_id' ] = "1342013"
66+ doc . data [ 'gist_filename' ] = "atom.xml"
67+ doc . content = content
68+ doc . output = Jekyll ::Renderer . new ( doc . site , doc ) . run
69+ end
70+
71+ it "produces the correct script tag" do
72+ expect ( output ) . to match ( /<script src="https:\/ \/ gist.github.com\/ #{ doc . data [ 'gist_id' ] } .js\? file=#{ doc . data [ 'gist_filename' ] } ">\s <\/ script>/ )
73+ end
74+ end
4675 end
4776
4877
You can’t perform that action at this time.
0 commit comments