From b4e2b700b59cd60f551c261000e6636a668943a2 Mon Sep 17 00:00:00 2001 From: Hans Fast Date: Mon, 2 Mar 2026 10:45:44 +0100 Subject: [PATCH] initial commit --- README.md | 27 +++++++++++++++++++++++++++ clientdata.ori | 2 ++ clients.yaml | 8 ++++++++ 3 files changed, 37 insertions(+) create mode 100644 README.md create mode 100644 clientdata.ori create mode 100644 clients.yaml diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc06fb2 --- /dev/null +++ b/README.md @@ -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")'` + + + + diff --git a/clientdata.ori b/clientdata.ori new file mode 100644 index 0000000..cd6d368 --- /dev/null +++ b/clientdata.ori @@ -0,0 +1,2 @@ +(clientid) => clients.yaml(clientid) + diff --git a/clients.yaml b/clients.yaml new file mode 100644 index 0000000..57bce34 --- /dev/null +++ b/clients.yaml @@ -0,0 +1,8 @@ +#clients.yaml +client1: + name: James Jamm + email: james@jamfactory.com +client2: + name: Sammy Sauk + email: sam@sockfactory.com +