initial commit

This commit is contained in:
Hans Fast 2026-03-02 10:45:44 +01:00
commit b4e2b700b5
3 changed files with 37 additions and 0 deletions

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# select data from an external source with Ori and close over it
Say we have a file somewhere else with all our clients:
```yaml
#clients.yaml
client1:
name: James Jamm
email: james@jamfactory.com
client2:
name: Sammy Sauk
email: sam@sockfactory.com
```
We want to maintain our client database in one place, and get client data for each of their websites without exposing other clients' data.
We can do this with function in an ori expression file. The function takes a clientid, and returns just that client. Origami's syntax supports passing an argument to a data file as if it were a function.
```
//clientdata.ori
(clientid) => /path/to/clients.yaml(clientid)
```
To get just James Jamm's data: `ori 'clientdata.ori("client1")'`

2
clientdata.ori Normal file
View File

@ -0,0 +1,2 @@
(clientid) => clients.yaml(clientid)

8
clients.yaml Normal file
View File

@ -0,0 +1,8 @@
#clients.yaml
client1:
name: James Jamm
email: james@jamfactory.com
client2:
name: Sammy Sauk
email: sam@sockfactory.com