hasura / kriti-lang

A minimal JSON templating language
Apache License 2.0
56 stars 9 forks source link

Template Literal Behavior #12

Closed solomon-b closed 2 years ago

solomon-b commented 3 years ago

Kriti's Template Literal format is:

`string text ${expression} string text`

Expressions are limited to path lookups, eg;

`string text ${$.event.name} string text`

where
  context= [ ("$", { "event": { "name": "foobar" } })]

We limited Template Literals in this way to simplify the implementation for our initial release.

It would be nice to be able to perform arbitrary operations inside template expressions, eg:

`Fifteen is ${a + b}`

Since Kriti maps Value -> Value we would need to cast all values to Value.String. We can use Data.Aeson.encode to serialize the Aeson values and then concat them into our string.

In the case of Map and List values, do we want to simply serialize the data structure or should we throw a runtime error?

solomon-b commented 2 years ago

Resolved by #27