Skip to content

Instantly share code, notes, and snippets.

@stasm
Last active October 23, 2023 06:48
Show Gist options
  • Save stasm/a7055c30a8e1eed040cd2e9fa1faf0df to your computer and use it in GitHub Desktop.
Save stasm/a7055c30a8e1eed040cd2e9fa1faf0df to your computer and use it in GitHub Desktop.

A message with a variable:

Hello, {$username}!

A message with an annotated variable:

{#input $date :datetime month=long day=numeric}
Today is {$date}.

A multi-variant message with one selector:

{#match {$count :plural}}
{#when 1} You have one new message.
{#when *} You have {$count} new messages.

A multi-variant message with two selectors:

{#input $invites :number maxFracDigits=0}
{#match {$invites :number} {$responses :number}}
{#when   0   *} You sent no invites.
{#when one   0} You sent {$invites} invite and received no responses.
{#when one one} You sent {$invites} invite and received {$responses} response.
{#when one   *} You sent {$invites} invite and received {$responses} responses.
{#when   *   0} You sent {$invites} invites and received no responses.
{#when   * one} You sent {$invites} invites and received {$responses} response.
{#when   *   *} You sent {$invites} invites and received {$responses} responses.

Same as above, but written on a single line:

{#input $invites :number maxFracDigits=0} {#match {$invites :number} {$responses
:number}} {#when 0 *} You sent no invites. {#when one 0} You sent {$invites} invite
and received no responses. {#when one one} You sent {$invites} invite and received
{$responses} response. {#when one *} You sent {$invites} invite and received
{$responses} responses. {#when * 0} You sent {$invites} invites and received no
responses.  {#when * one} You sent {$invites} invites and received {$responses}
response. {#when * *} You sent {$invites} invites and received {$responses}
responses.

A message with a variable:

Hello, {$username}!

A message with an annotated variable:

{# input {$date :datetime month=long day=numeric}
   {Today is {$date}.}
#}

A multi-variant message with one selector:

{# match {$count :plural}
   when 1 {You have one new message.}
   when * {You have {$count} new messages.}
#}

A multi-variant message with two selectors:

{# input {$invites :number maxFracDigits=0}
   match {$invites :number} {$responses :number}
   when   0   * {You sent no invites.}
   when one   0 {You sent {$invites} invite and received no responses.}
   when one one {You sent {$invites} invite and received {$responses} response.}
   when one   * {You sent {$invites} invite and received {$responses} responses.}
   when   *   0 {You sent {$invites} invites and received no responses.}
   when   * one {You sent {$invites} invites and received {$responses} response.}
   when   *   * {You sent {$invites} invites and received {$responses} responses.}
#}

Same as above, but written on a single line:

{# input {$invites :number maxFracDigits=0} match {$invites :number} {$responses
:number} when 0 * {You sent no invites.} when one 0 {You sent {$invites} invite
and received no responses.} when one one {You sent {$invites} invite and received
{$responses} response.} when one * {You sent {$invites} invite and received
{$responses} responses.} when * 0 {You sent {$invites} invites and received no
responses.} when * one {You sent {$invites} invites and received {$responses}
response.} when * * {You sent {$invites} invites and received {$responses}
responses.} #}

A message with a variable:

Hello, {$username}!

A message with an annotated variable:

%input {$date :datetime month=long day=numeric}
Today is {$date}.

A multi-variant message with one selector:

%match {$count :plural}
%[1] You have one new message.
%[*] You have {$count} new messages.

A multi-variant message with two selectors:

%input {$invites :number maxFracDigits=0}
%match {$invites :number} {$responses :number}
%[  0   *] You sent no invites.
%[one   0] You sent {$invites} invite and received no responses.
%[one one] You sent {$invites} invite and received {$responses} response.
%[one   *] You sent {$invites} invite and received {$responses} responses.
%[  *   0] You sent {$invites} invites and received no responses.
%[  * one] You sent {$invites} invites and received {$responses} response.
%[  *   *] You sent {$invites} invites and received {$responses} responses.

Same as above, but written on a single line:

%input {$invites :number maxFracDigits=0} %match {$invites :number} {$responses
:number} %[0 *] You sent no invites. %[one 0] You sent {$invites} invite
and received no responses. %[one one] You sent {$invites} invite and received
{$responses} response. %[one *] You sent {$invites} invite and received
{$responses} responses. %[* 0] You sent {$invites} invites and received no
responses. %[* one] You sent {$invites} invites and received {$responses}
response. %[* *] You sent {$invites} invites and received {$responses}
responses.

A message with a variable:

Hello, {$username}!

A message with an annotated variable:

{# input {$date :datetime month=long day=numeric} #}
Today is {$date}.

A multi-variant message with one selector:

{# match {$count :plural} #}
{[1]} You have one new message.
{[*]} You have {$count} new messages.

A multi-variant message with two selectors:

{# input {$invites :number maxFracDigits=0}
   match {$invites :number} {$responses :number}
#}
[[  0   *]] You sent no invites.
[[one   0]] You sent {$invites} invite and received no responses.
[[one one]] You sent {$invites} invite and received {$responses} response.
[[one   *]] You sent {$invites} invite and received {$responses} responses.
[[  *   0]] You sent {$invites} invites and received no responses.
[[  * one]] You sent {$invites} invites and received {$responses} response.
[[  *   *]] You sent {$invites} invites and received {$responses} responses.

Same as above, but written on a single line:

{#input {$invites :number maxFracDigits=0} match {$invites :number} {$responses
:number}#} [[0 *]] You sent no invites. [[one 0]] You sent {$invites} invite
and received no responses. [[one one]] You sent {$invites} invite and received
{$responses} response. [[one *]] You sent {$invites} invite and received
{$responses} responses. [[* 0]] You sent {$invites} invites and received no
responses. [[* one]] You sent {$invites} invites and received {$responses}
response. [[* *]] You sent {$invites} invites and received {$responses}
responses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment