forked from sendgrid/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap_column.rb
More file actions
48 lines (39 loc) · 1.05 KB
/
Copy pathbootstrap_column.rb
File metadata and controls
48 lines (39 loc) · 1.05 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
#
# Author: Matt Bernier
# Make a bootstrap column
#
# Outputs the HTML for a bootstrap column of size 4 with id "best_column"
#
# {% html_column md-4 best_column %}
# Some content
# {% endhtml_column %}
# ...
# <div id="best_column" class="col-md-4">
# <p>Some content</p>
# </div>
#
module Jekyll
class Bootstrap_Column < Liquid::Block
def initialize(tag_name, markup, tokens)
parameters = markup.shellsplit
@size = "col-#{parameters[0]}"
@class = defined?(parameters[1]) ? " #{parameters[1]}" : ""
@id = parameters[2];
if defined?(parameters[2].to_str)
if !empty?(parameters[2].to_str)
@id = "id=\"#{parameters[2]}\""
end
end
super
end
def render(context)
output = super
output = <<HTML
<div #{@id} class="#{@size}#{@class}"><p>#{output}</p></div>
HTML
#html = Kramdown::Document.new(output).to_html
return Liquid::Template.parse(output).render context
end
end
end
Liquid::Template.register_tag('html_column', Jekyll::Bootstrap_Column)