forked from sendgrid/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_error_table.rb
More file actions
34 lines (34 loc) · 879 Bytes
/
Copy pathapi_error_table.rb
File metadata and controls
34 lines (34 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#require 'kramdown'
module Jekyll
class APIErrorTable < Liquid::Block
def initialize(tag_name, markup, tokens)
parameters = markup.shellsplit
@name = parameters[0]
@description = parameters[1]
@identifier = @name.gsub(".","_")
@tag = parameters[2]
super
end
def render(context)
output = super
output = <<HTML
{% anchor h3 #{@tag}%}#{@name}{% endanchor %}
#{@description}
<table class="apitable" name="#{@identifier}">
<tbody>
<tr>
<th colspan="1">Error Code</th>
<th class="details-header">Error Message</th>
<th>Details</th>
<th></th>
</tr>
#{output}
</tbody>
</table>
HTML
#html = Kramdown::Document.new(output).to_html
return Liquid::Template.parse(output).render context
end
end
end
Liquid::Template.register_tag('api_error_table', Jekyll::APIErrorTable)