forked from sendgrid/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap_row.rb
More file actions
65 lines (59 loc) · 1.57 KB
/
Copy pathbootstrap_row.rb
File metadata and controls
65 lines (59 loc) · 1.57 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#
# Author: Matt Bernier
# Make a bootstrap row
#
# Outputs the HTML for a bootstrap row with id "best_row"
#
# {% html_row md-4 best_row %}
# Wheeee!
# {% endhtml_row %}
# ...
# <div id="best_row" class="row">
# Wheeee!
# </div>
#
# Use with html_column to output a proper bootstrap row and column pairing
#
# {% html_row md-4 best_row %}
# {% html_column md-4 best_column %}
# Some content
# {% endhtml_column %}
# {% html_column md-4 best_column2 %}
# Some content
# {% endhtml_column %}
# {% html_column md-4 best_column3 %}
# Some content
# {% endhtml_column %}
# {% endhtml_row %}
# ...
# <div id="best_row" class="row">
# <div id="best_column" class="col-md-4">
# <p>Some content</p>
# </div>
# <div id="best_column2" class="col-md-4">
# <p>Some content</p>
# </div>
# <div id="best_column3" class="col-md-4">
# <p>Some content</p>
# </div>
# </div>
#
module Jekyll
class Bootstrap_Row < Liquid::Block
def initialize(tag_name, markup, tokens)
parameters = markup.shellsplit
@class = defined?(parameters[0]) ? " #{parameters[1]}" : ""
@id = defined?(parameters[1]) ? "id=\"#{parameters[0]}\"" : ""
super
end
def render(context)
output = super
output = <<HTML
<div #{@id} class="row#{@class}">#{output}</div>
HTML
#html = Kramdown::Document.new(output).to_html
return Liquid::Template.parse(output).render context
end
end
end
Liquid::Template.register_tag('html_row', Jekyll::Bootstrap_Row)