Skip to content

Instantly share code, notes, and snippets.

@joelverhagen
Created February 17, 2012 04:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelverhagen/1850654 to your computer and use it in GitHub Desktop.
Save joelverhagen/1850654 to your computer and use it in GitHub Desktop.
Jekyll JSON Filter

This is a plugin meant for Jekyll.

This filter is described at the Shopify Liquid wiki, but somehow didn't make it into the general repository.

Just plop this guy in your _plugins directory and use it like this:

var title = {{ page.title | json }};

Easy!

require "rubygems"
require "json"
module JsonFilter
def json(input)
input.to_json
end
Liquid::Template.register_filter self
end
@axelheer
Copy link

axelheer commented Sep 6, 2014

You can use the jsonify filter instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment