#Jekyll-HexToRGB
A super simple hex conversion Jekyll Liquid filter plugin.
This was made because I needed something to convert a hexadecimal string in the
form "RRGGBB"
into the decimal in an array of form [R, G, B]
Assuming you are using a Jekyll site setup
_plugins
directory in your site, create onehex_to_rgb.rb
into your plugins
directoryThis will add the filter hex_to_rgb
to your project. Here are some examples of
it being used:
{{ "aabbcc" | hex_to_rgb }}
# => [170, 187, 204]
{{ "abc" | hex_to_rgb }}
# => [170, 187, 204]
{{ "0a0b0c" | hex_to_rgb }}
# => [10, 11, 12]
This filter acts differently based on the length of the sting given
This will parse and convert strings of ANY length. (Not just strings of 3 or 6
characters). Doing something like {{ "12345" | hex_to_rgb }}
would return [1, 2, 3, 4, 5]