Project

rehab

0.0
No commit activity in last 3 years
No release in over 3 years
Simple, portable template language
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
>= 0
>= 0

Runtime

>= 0
>= 0
 Project Readme

Rehab

Simple, Portable Template Language.

Installation

Add this line to your application's Gemfile:

gem 'rehab'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rehab

Usage

You can use Rehab like any tilt-like template.

Rehab::Template.new(options) { "template_source" }.render(scope)

See spec/integration_spec.rb and sample.html for more documentation.

Options

# OPTIONAL
options[:file_provider] =>
	# an object with a .call method that returns file content from a path string
	->(path){  File.read(path) }

Syntax Overview

The goal is to have very little syntax, other than plain ruby and a couple conveniences for templating. It may be harnessing the full power of ruby, but remember: just because you can doesn't mean you should.

Interpolation:

<p>{{ greeting }} World!<p>

Control Flow:

# if greeting.empty?
	<p>I have nothing to say<p>
# end

Block:

# 3.times.do |n|
	<p>{{ n }}. Why didn't I use an ordered list?</p>
# end

Optional "Short" Block (without the 'Do'):

# 3.times
	<blink>Click Me!<blink>
# end

Include partial:

# include my_partial.html

Include partial for each item in a collection:

# include awesome-post.html for post in posts

Future Plans

  • It would be awesome to have an implementation not tied to Ruby, but... Ruby is pretty.
  • Implement simple filter syntax, see todo.html