https://github.com/loic-sharma/moji
A simple template parser
https://github.com/loic-sharma/moji
Last synced: 3 months ago
JSON representation
A simple template parser
- Host: GitHub
- URL: https://github.com/loic-sharma/moji
- Owner: loic-sharma
- Created: 2012-05-09T22:20:40.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-05-09T22:25:55.000Z (about 13 years ago)
- Last Synced: 2025-02-02T12:48:35.479Z (5 months ago)
- Language: PHP
- Size: 89.8 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Moji - A simple template parser
Moji lets you register helpers to parse in your template.
### Examples
**Parsing Content**
Parsing content is as easy as pie. Simply pass the content into Moji's parse method and you're done!
$content = 'This is some content with some {{tags}}. Tags can have parameters! {{like this="tag"}}';
Moji::parse($content);
**Basic Helper**
Creating a helper is very easy:
Moji::helper('helloworld', function()
{
return 'Hello World!';
});This would replace:
{{helloworld}}
**Helper Parameters**
Helpers can have parameters:
Moji::helper('show', function($params)
{
return $params['message'];
});This would parse:
{{show message="This is the parameter"}}
**Miscellaneous**
The name of the helper is very flexible:
Moji::helper('cms:module:method', function($params)
{
// Do something here
});This would parse the following tag:
{{cms:module:method param1="value1"}}