Mike Slinn

evaluate

Published 2020-10-03. Last modified 2023-05-18.
Time to read: 1 minutes.

This page is part of the jekyll_plugins collection.

jekyll_eval_filter contains a Liquid filter called evaluate that returns the result of evaluating a Ruby expression.

CAUTION

This filter can evaluation any Ruby expression. No limitations are imposed.

If you use this filter, only allow trusted and verified people to edit the source of your Jekyll website.

With great power comes great responsibility.

Usage:

HTML or markdown
{{ "1 + 2" | evaluate }} returns 3

The following potentially destroys your system:

HTML or markdown
{{ 'sudo rm -rf /' | evaluate }}

On a clear disk you can seek forever.

Installation

Add the following highlighted line to your Jekyll project's Gemfile, within the jekyll_plugins group:

Gemfile
group :jekyll_plugins do 
  gem 'jekyll_eval_filter'
end 

And then execute:

Shell
$ bundle
* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.