Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haarcuba/yaml_mako
use mako templating in your YAML files
https://github.com/haarcuba/yaml_mako
Last synced: about 16 hours ago
JSON representation
use mako templating in your YAML files
- Host: GitHub
- URL: https://github.com/haarcuba/yaml_mako
- Owner: haarcuba
- Created: 2017-01-22T23:12:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-26T18:39:58.000Z (over 4 years ago)
- Last Synced: 2024-11-01T03:05:37.333Z (19 days ago)
- Language: Python
- Homepage: https://haarcuba.github.io/yaml_mako/
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# YAML-MAKO
These are the facts:
* [Mako](http://www.makotemplates.org/) templates are great.
* [YAML](https://en.wikipedia.org/wiki/YAML) is great.Let's have them both!
# Installation
$ pip install yaml-mako
# Example
Here's our yaml document, describint a general subscription, say to a newsletter:
```yaml
---
name: "subscription"
details:
start time: ${start_date}
end time: ${end_date}
comment: dates should appear above after temlating
```If you load this as plain `YAML`, you will get the equivalent of
```python
{'details': {'comment': 'dates should appear above after temlating',
'end time': '${end_date}',
'start time': '${start_date}'},
'name': 'subscription'}
```Using `yaml-mako` you can to this:
```python
import yaml_mako
import pprint
import datetimestream = open('example.yaml')
today = datetime.date.today()
tomorrow = today + datetime.timedelta(1)
pprint.pprint(yaml_mako.load(stream, start_date = today, end_date = tomorrow))
```And we get:
```python
{'details': {'comment': 'dates should appear above after temlating',
'end time': datetime.date(2017, 1, 24),
'start time': datetime.date(2017, 1, 23)},
'name': 'subscription'}
```