Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Minimum Operational Template

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 benchmarks
Octocat-spinner-32 bin
Octocat-spinner-32 extras
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gems
Octocat-spinner-32 .gitignore
Octocat-spinner-32 AUTHORS
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Rakefile
Octocat-spinner-32 mote.gemspec


Minimum Operational Template.


Mote is a very simple and fast template engine.


Usage is very similar to that of ERB:

template = Mote.parse("This is a template") #=> "This is a template"

Silly example, you may say, and I would agree. What follows is a short list of the different use cases you may face:

% if user == "Bruno"
  {{user}} rhymes with Piano
% elsif user == "Brutus"
  {{user}} rhymes with Opus
% end

Control flow

Lines that start with % are evaluated as Ruby code.


Whatever it is between {{ and }} gets printed in the template.


There's nothing special about comments, it's just a # inside your Ruby code:

% # This is a comment.

Block evaluation

As with control instructions, it happens naturally:

% 3.times do |i|
% end


The values passed to the template are available as local variables:

example = Mote.parse("Hello {{name}}", self, [:name])
assert_equal "Hello world", "world")
assert_equal "Hello Bruno", "Bruno")

Please note that the keys in the parameters hash must be symbols.


There's a helper available in the Mote::Helpers module, and you are free to include it in your code. To do it, just type:

include Mote::Helpers

Using the mote helper

The mote helper receives a file name and a hash and returns the rendered version of its content. The compiled template is cached for subsequent calls.

assert_equal "***\n", mote("test/basic.mote", n: 3)

Command line tool

Mote ships with a command line tool to render mote templates. The result is redirected to standard output.

mote FILE [param1 value1 ... paramN valueN]

The extra parameters supplied will be passed to the template. Note that all the parameter values will be treated as strings.

Example usage

If your template is called foo.mote, you can render it with the following command:

mote foo.mote

To write the result to a new file, just redirect the output:

mote foo.mote > foo.html

If the template uses a local variable bar, you can pass a value from the command line:

mote foo.mote bar 42


You can install it using rubygems.

$ gem install mote
Something went wrong with that request. Please try again.