An open API service indexing awesome lists of open source software.

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.

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.