forked from sendgrid/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_error_table_row.rb
More file actions
34 lines (34 loc) · 921 Bytes
/
Copy pathapi_error_table_row.rb
File metadata and controls
34 lines (34 loc) · 921 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 APIErrorTableRow < Liquid::Tag
def initialize(tag_name, markup, tokens)
parameters = markup.shellsplit
@error_code = parameters[0]
@temp_error_code = Integer(@error_code)
if (@temp_error_code >= 200)
if (@temp_error_code >= 400)
if (@temp_error_code >= 500)
@error_code_css = 500
else
@error_code_css = 400
end
else
@error_code_css = 200
end
end
super
end
def render(context)
output=<<HTML
<tr class="depth-1">
<td colspan="2"" class="param status-#{@error_code_css}">#{@error_code}</td>
<td></td><td></td>
</tr>
#{output}
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_row', Jekyll::APIErrorTableRow)