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
5
5
def render ( context )
6
6
if tag_contents = determine_arguments ( @markup . strip )
7
7
gist_id , filename = tag_contents [ 0 ] , tag_contents [ 1 ]
8
+ if context [ gist_id ]
9
+ gist_id = context [ gist_id ]
10
+ end
11
+ if context [ filename ]
12
+ filename = context [ filename ]
13
+ end
8
14
gist_script_tag ( gist_id , filename )
9
15
else
10
16
raise ArgumentError . new <<-eos
Original file line number Diff line number Diff line change 43
43
expect ( output ) . to match ( /<script src="https:\/ \/ gist.github.com\/ #{ gist } .js\? file=#{ filename } ">\s <\/ script>/ )
44
44
end
45
45
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
46
75
end
47
76
48
77
You can’t perform that action at this time.
0 commit comments