Skip to content

ravishi/radius-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radius for PHP

This is my intent to port the Radius template language to PHP.

Radius is a powerful tag-based template language 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...).

For PHP 5.3 or higher.

Usage

require_once '/path/to/radius/lib/Radius/Autoloader.php';
Radius\Autoloader::register();

// Create a context and define some tags
$context = new Radius\Context();
$context->defineTags(array(
	'hello' => function () {
		return 'Hello world';
	},
	'repeat' => function ($tag) {
		$number = $tag->getAttr('times', 1);
		$result = '';
		for ($i = 0; $i < $number; ++$i) {
			$result .= $tag->expand();
		}
		return $result;
	},
	));

// Create a parser to parse tags that begin with 'r:'
$parser = new Radius\Parser($context, 'r');

// Parse and outputs the result
echo $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!

Development

This is not complete. If you feel interested and want to contribute, please contact me.

About

A cool template language for PHP.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages