New plugin env.rb to make env vars available in templates

This commit is contained in:
David A. Harding 2015-09-04 12:24:17 -04:00
parent e4b8f0c7dd
commit adef074df5
No known key found for this signature in database
GPG key ID: 4B29C30FF29EC4B7
2 changed files with 24 additions and 0 deletions

View file

@ -3,5 +3,9 @@ rvm:
- "2.0.0"
sudo: false
cache: bundler
env:
# http://docs.travis-ci.com/user/environment-variables/#Global-Variables
global:
- BITCOINORG_BUILD_TYPE=deployment
script: make travis

20
_plugins/env.rb Normal file
View file

@ -0,0 +1,20 @@
# This file is licensed under the MIT License (MIT) available on
# http://opensource.org/licenses/MIT.
## env.rb takes select environmental variables and makes them available
## to the site templates. Currently, only variables starting with
## BITCOINORG_ are exported
module Jekyll
class EnvGenerator < Generator
def generate(site)
## If necessary, initialize env hash table
site.config["env"] = site.config["env"] ? site.config["env"] : {}
## Load matching environmental variables in to array
ENV.keys.grep /^BITCOINORG_/ do |key|
site.config['env'].merge!({ key => ENV[key] })
end
end
end
end