• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 16 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small, but powerful tag-based template language for Ruby modeled after the ones used in MovableType and TextPattern. It has tags similar to XML, but can be used to generate any form of plain text (HTML, e-mail, etc...).

Radius – Powerful Tag-Based Templates¶ ↑

<img src=“https://travis-ci.org/jlong/radius.png?branch=master” alt=“Build Status” /> <img src=“https://codeclimate.com/github/jlong/radius.png” /> <img src=“https://coveralls.io/repos/jlong/radius/badge.png” alt=“Coverage Status” />

Radius is a powerful tag-based template language for Ruby inspired by the template languages used in MovableType and TextPattern. It uses tags similar to XML, but can be used to generate any form of plain text (HTML, e-mail, etc…).

Usage¶ ↑

With Radius, it is extremely easy to create custom tags and parse them. Here’s a small example:

require 'radius'

# Define tags on a context that will be available to a template:
context = Radius::Context.new do |c|
  c.define_tag 'hello' do
    'Hello world'
  end
  c.define_tag 'repeat' do |tag|
    number = (tag.attr['times'] || '1').to_i
    result = ''
    number.times { result << tag.expand }
    result
  end
end

# Create a parser to parse tags that begin with 'r:'
parser = Radius::Parser.new(context, :tag_prefix => 'r')

# Parse tags and output the result
puts parser.parse(%{A small example:\n<r:repeat times="3">* <r:hello />!\n</r:repeat>})

Output:

A small example:
* Hello world!
* Hello world!
* Hello world!

Quick Start¶ ↑

Read the QUICKSTART file to get up and running with Radius.

Requirements¶ ↑

Radius does not have any external requirements for using the library in your own programs.

Ragel is required to create the ruby parser from the Ragel specification, and both Ragel and Graphviz are required to draw the state graph for the parser.

Installation¶ ↑

It is recommended that you install Radius using the RubyGems packaging system:

% gem install --remote radius

License¶ ↑

Radius is released under the MIT license and is copyright © 2006-2010 John W. Long. A copy of the MIT license can be found in the LICENSE file.

Roadmap¶ ↑

This is a prioritized roadmap for future releases:

  1. Clean up the current code base. [Done]

  2. Add support for multi-level contexts: tags should be able to be defined to only be valid within other sets of tags. [Done]

  3. Create a simple DSL for defining contexts. [Done]

  4. Optimize for speed, modify scan.rl to emit C.

Development¶ ↑

The latest version of Radius can be found on RubyForge:

rubyforge.org/projects/radius

Experimental and development versions of Radius can be found on Github:

github.com/jlong/radius

If you are interested in helping with the development of Radius, feel free to fork the project on GitHub and send me a pull request.

John Long

wiseheartdesign.com

More Repositories

1

css-spinners

Simple CSS spinners and throbbers made with CSS and minimal HTML markup.
CSS
924
star
2

serve

Serve is a small Rack-based web server and rapid prototyping framework for Web applications (specifically Rails apps). Serve is meant to be a lightweight version of the Views part of the Rails MVC. This makes Serve an ideal framework for prototyping Rails applications or creating simple websites. Serve has full support for Rails-style partials and layouts.
Ruby
836
star
3

popupjs

A prototype/lowpro based Facebook-style windowing solution
JavaScript
58
star
4

rubyblue

A collection of themes for different text editors that mimic the colors used in the code samples on ruby-lang.org
Vim Script
50
star
5

statusjs

Allows you to display a status message when submiting a form or performing other time consuming tasks
JavaScript
28
star
6

TrelloApp

A simple unofficial wrapper application for Trello.com. No longer maintained. Superseded by Trello's own app: https://apps.apple.com/app/trello/id1278508951?ls=1&mt=12
Swift
23
star
7

cheap-sass-tricks

CSS
22
star
8

radiant-bespin-editor-extension

Replaces all textareas in Radiant with the Bespin editor
JavaScript
18
star
9

feedchamp

A simple camping application that makes it easy to aggregate a bunch of feeds into a single website.
Ruby
10
star
10

sass-convert.vim

Simple commands for Vim for converting Sass from SCSS to Sass and back.
Vim Script
8
star
11

acoustic

A lightweight Ruby Web framework experiment based loosely on Django and Rails
Ruby
6
star
12

cookbook

A simple cookbook application designed to demo Rails 3. Made with Devise for authentication and Twitter Bootstrap for styles.
Ruby
5
star
13

javascript_spec

4
star
14

serve-heroku

An example Serve project deployed on Heroku
Ruby
4
star
15

MacRubyClock

A very simple clock written in MacRuby. Uses NSTimer and a label to display the current time.
Ruby
3
star
16

serve-slim

An example Serve project with Slim
Ruby
3
star
17

ChessClocks

A simple chess clock application for the iPhone
Objective-C
2
star
18

ruby-presentation

The source code for a presentation that John W. Long and Ryan Platte put together in 2005
Ruby
2
star
19

radiant3

A Rails 3 update and reboot of Radiant
Ruby
1
star
20

ChessClocksAssets

1
star
21

radiant

Ruby
1
star
22

snakejs

The micro selector and events library for IE8+ perfectly suited for widgets and simple applications or websites.
JavaScript
1
star
23

test_helpers

An older Rails plugin that adds support for test helpers
Ruby
1
star
24

css-workshop

The source files from a workshop I did several years ago. Students were supposed to style the provided HTML so that it looked like the provided mockup.
1
star
25

oxygen-moogle-example

CSS
1
star
26

styleguide

Gulp workflow for a styleguide
JavaScript
1
star
27

snakes-and-rubies

The source code for an application that collected questions for a debate that occurred between David Heinemeier Hansson and Adrian Holovaty about Rails and Django.
Ruby
1
star
28

angular-and-d3

Example code from my presentation on Angular and D3
JavaScript
1
star
29

stealth

Experimental work on a Javascript game
JavaScript
1
star
30

abstract_testcases

An older Rails plugin that adds support for abstract test cases
Ruby
1
star
31

hello-c

Canonical hello world program in C
Shell
1
star
32

serve-coffee

Basic demo of how to use Serve with Coffee Script. The tricky part is that you need to serve it from your views directory and make sure the layout is appropriate.
Ruby
1
star