https://github.com/d-plaindoux/page
Bi-directional template language providing parser and generator capabilities.
https://github.com/d-plaindoux/page
Last synced: 5 days ago
JSON representation
Bi-directional template language providing parser and generator capabilities.
- Host: GitHub
- URL: https://github.com/d-plaindoux/page
- Owner: d-plaindoux
- License: lgpl-2.1
- Created: 2014-01-09T06:40:10.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-25T10:18:04.000Z (over 12 years ago)
- Last Synced: 2025-10-20T05:52:08.303Z (9 months ago)
- Language: Scala
- Size: 207 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PaGe
A Bi-directional template language providing Parser and Generator capabilities.
## Syntax
```
template ::=
| (definition| environment | freeText)*
definition ::=
| "@DEFINE" name "[|" "|]"
| "@SET" name "[|" "|]"
| "@USE" name "[|" "|]"
environment ::=
| "@REP" separator? name? "[|" "|]"
| "@VAL" name? "[|" "|]"
| "@OPT" name? "[|" "|]"
| "@OR" name? ("[|" "|]")+
freeText ::=
|
name ::=
| "::"
separator? ::=
| "(" ")"
```
## Example of Generation
Consider the following JSON fragment
```
{
"first": "John",
"last": "Doe",
"age": 39,
"sex": "M",
"salary": 70000,
"registered": true,
"interests": [ "Reading", "Mountain Biking", "Hacking" ]
}
```
and the following simple template.
```html
@DEFINE::CR[|
|]
@VAL::first @VAL::last is interested by:
@REP( and@USE::CR)::interests[| - @VAL|]
```
The generation produces the following simple result:
```
John Doe is interested by:
- Reading and
- Mountain Biking and
- Hacking
```
## Example of Extraction
Consider the following fragment
```
John Doe is interested by:
- Reading and
- Hacking
```
and the following simple template.
```html
@DEFINE::CR[|
|]
@VAL::first @VAL::last is interested by:
@REP( and@USE::CR)::interests[| - @VAL|]
```
The extraction produces the following fragment:
```
{
"first": "John",
"last": "Doe",
"interests": [ "Reading", "Hacking" ]
}
```
## License
Copyright (C)2014 D. Plaindoux.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.