Thought Experiment: 1-File Apps (Part 3)


You should read Thought Experiment: One-File Apps (Part 1) so that you know what this article is about.

Example: Hacker News

title = My News Feed
api = url('')
posts = api('posts')

post_title(post, i) = '{i}. ' <link text=post.title url=post.url>
comments_link(post) = <link text=f'{post.comments.size} comments' url=post.comments.url>
author_link(post) = <link>

list_item(post, i) = <column
  post_title(post, i)
  comments_link(post) ' by ' author_link(post) ' on {}'

<list bind=posts template(post, i)=list_item >

<list(posts) template(post, i)=  # Use `list(posts)` instead of `list bind=posts` because bind is done so often with list that we can save text
    '{i}. ' <link text=post.title url=post.url>
    comments_link(post) ' by ' author_link(post) ' on {}'

<link text='Top' url=#top>

Interested in learning more about this Anonsage language? Click here

<TIL: Symbolic links don't work by default in Windows, even in Git Bash!