@or(...values)

Returns the first truthy value: a value that isn’t false, null, undefined, or any of the other similar values in JavaScript.

This can be useful in situations like templates to provide a default value for a field that may or may not be present in an input document.

Example: a blog post template uses @or to define a default title.

$ ori blostPost.ori
(post) => `<html>
  <head>
    <title>${ @or(post/title, "A blog post") }</title>
  </head>
  <body>
    ${ post/@text }
  </body>
</html>
`

If a blog post defines a title, that title is preferred:

$ cat posts/post1.html
---
title: The First Post
---

Here's the text of my first post.

$ ori blogPost.ori posts/post1.html
<html>
  <head>
    <title>The First Post</title>
  </head>
  <body>
    
Here's the text of my first post.

  </body>
</html>

But if a post fails to define a title, the template’s default title is used:

$ cat posts/post2.html
---
# No title
---

Here's the text of my second post.

$ ori blogPost.ori posts/post2.html
<html>
  <head>
    <title>A blog post</title>
  </head>
  <body>
    
Here's the text of my second post.

  </body>
</html>