Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
NO LAme TEmplate System for Ruby
branch: master

This branch is 48 commits behind antirez:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README
nolate.rb
test.rb

README

Nolate - NO LAme TEmplate system

OVERVIEW
--------

Nolate is a template system similar to erb that is designed for not consuming
some huge amount of CPU without a good reason. It is written in pure Ruby.
Nolate is distributed under a two clause BSD license for max freedom.

Templates can include code inside <%= %> that is evaluated with eval() and
substituted to the string.

Also occurrences of <%#something%> are substituted with the value of the
hash field :something of an additional hash passed to nolate() or nlt()
functions.

IS IT SUPER FAST?
-----------------

Fast enough that a small template substitution is not measurable by the
apache benchmark against a sample Sinatra application.
Surprisingly this is not as common as it should be.

HOW TO USE IT?
--------------

Nolate consists of just three functions. The first is nolate() that is the core
of the template system:

    nolate("The sum is <%= 2+2 %> Also substitute <%#myfield%> ok",
           {:myfield => 10})

The array is optional, if you don't have <%#%> style substitutions you can
simply omit it.

The second function is nlt(), and is used to also handle loading the template
from a 'views' directory. The above example can be translated using nlt()
just creating a file 'views/index.nlt' with the following content:

The sum is <%= 2+2 %> Also substitute <%#myfield%> ok

Then we can use nlt() calling:

    nlt("index.nlt", {:myfield => "something"})

the nlt() funciton will take care to cache templates into memory.
In order to flush this templates to force reloading just call the third and
final provided function:

    nlt_flush_templates()

CONTRIBUTE
----------

Please send me pull requests: http://github.com/antirez/nolate

So far thank you to: @soveran, @brmichel, @JEG2

It is not too late...
Salvatore
Something went wrong with that request. Please try again.