Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Percent encoding for URI conforming to RFC 3986. Ref: http://tools.ietf.org/html/rfc3986#page-12

View url_encode.rb
1 2 3 4 5 6 7 8 9 10 11 12
require 'liquid'
require 'uri'
 
# Percent encoding for URI conforming to RFC 3986.
# Ref: http://tools.ietf.org/html/rfc3986#page-12
module URLEncoding
def url_encode(url)
return URI.escape(url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end
end
 
Liquid::Template.register_filter(URLEncoding)

How is this plugin supposed to be used while writing my template?

see https://github.com/mojombo/jekyll/wiki/Liquid-Extensions

so you would probably want sth like this:

{{ post.title | URLEncoding }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.