UpAndRunning

a simple, generic templating system with the goal of helping you rapidly bootstrap new projects

Installation

gem install 'up_and_running'

Usage

The main interface for using UpAndRunning is the unr command. It accepts a feature name, searches the UP_AND_RUNNING_FEATURE_LOAD_PATH for the correct compiler, copies any template files, and compiles any ERB.

Compilers consist of two things:

  • a compiler class (such as gem.rb)
  • an optional template directory with the same name (such as gem/)

Everything in the template directory will be copied over into the output directory. If there are any ERB templates, those will be compiled with the @scope variable from the compiler instance

By default features are loaded from ~/.up_and_running/features.

Here is a sample:

# ~/.up_and_running/sample.rb
class Sample < UpAndRunning::Compiler; end

# ~/.up_and_running/sample/hello.erb
Hello <%= username %>

Then you can just call the unr command with the name of your feature. The -s option takes a comma-separated list of = separated key-value pairs which will be merged into the scope used to compile the templates. There is also a -o option which can be used to specify the output directory for the compiled templates (uses current directory by default)

unr sample -s username=jbodah

This will compile the templates and output them into your output directory:

$ tree
└── hello

Compilers also support before_compile and after_compile hooks. Just define those methods:

class MyCompiler < UpAndRunning::Compiler
  def before_compile
    puts 'hello world'
  end
end