-
Notifications
You must be signed in to change notification settings - Fork 205
Build Time Templates
sgonyea edited this page Feb 5, 2013
·
1 revision
One feature of Warbler is the inclusion of ERB (or other) templates, which get processed at the time that thewarble
command is run. This allows you to bundle a variety of information along with your application, which is especially useful for remote debugging/monitoring/sanity-checking.
To take advantage of these Templates, you can create a template file (e.g.config/templates/env_vars.rb
):
ENV['MYPROJECT_GIT_SHA'] = '<%= `git rev-parse HEAD`.strip %>'
ENV['MYPROJECT_GIT_BRANCH'] = '<%= `git rev-parse --abbrev-ref HEAD`.strip %>'
ENV['MYPROJECT_BUILT_AT'] = '<%= Time.now.to_s %>'
ENV['RACK_ENV'] ||= 'qa'
In your config/warble.rb
file, simply include the line:
config.init_contents << "config/templates/env_vars.erb"
The erb
file extension will be detected by Warbler, and it will be run through ERB. Any other file extension will be read in as a raw file.