Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/_plugins/jekyll-color-picker.rb
1677 views
1
# frozen_string_literal: true
2
3
module Jekyll
4
module Tags
5
# Convert a color into a cute little box
6
class ColorPickerTag < Liquid::Tag
7
def initialize(tag_name, text, tokens) # :nodoc:
8
super
9
@text = text.strip
10
end
11
12
##
13
# This function renders the color box
14
# Params:
15
# +context+:: The context of the page
16
#
17
# Example:
18
#
19
# {% color_picker #ff0000 %}
20
def render(_context)
21
"<span style='background-color:#{@text};border-radius:3px;border:1px solid #000;width:12px;" \
22
"height:12px;margin-right:5px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"
23
end
24
end
25
end
26
end
27
28
Liquid::Template.register_tag('color_picker', Jekyll::Tags::ColorPickerTag)
29
30