You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Beauty contest: add the hybrid variant
* Beauty contest: add the templating language variant
* Beauty contest: add the double sigils for code mode variant
* 3b. Switch from |[] to #[] for keys
* Extend the comparison table
* Rename 0a to 2a
| 5 | Use blocks for declarations and body | -- | - | + | - | - | - |
20
23
| 5a | Use blocks for declarations but sigils for selectors | + | -- | + | - | - | - |
@@ -121,6 +124,40 @@ Hello {$var}, you have a {$foo}
121
124
{#match {$foo :function option=value}{$bar :function option=value}} {#when a b} {{ {$foo} is {$bar} }} {#when x y} {{ {$foo} is {$bar} }} {#when * *} {| |}{$foo} is {$bar}{| |}
122
125
```
123
126
127
+
## 1b. Templating Language
128
+
129
+
Same as 1, but directly inspired by existing templating languages.
130
+
Leverages the familiarity with established templating solutions,
131
+
such as [Jinja](https://jinja.palletsprojects.com/en/3.1.x/), [Twig](https://twig.symfony.com), and [Liquid](https://shopify.github.io/liquid/).
132
+
133
+
```
134
+
Hello world!
135
+
136
+
Hello {{ $user }}
137
+
138
+
{% input $var :function option=value %}
139
+
Hello {{ $var }}
140
+
141
+
{% input $var :function option=value %}
142
+
{% local $foo = $bar :function option=value %}
143
+
Hello {{ $var }}, you have a {{ $foo }}
144
+
145
+
{% match {$foo} {$bar} %}
146
+
{% when foo bar %} Hello {{ $foo }} you have a {{ $var }}
147
+
{% when * * %} {{ $foo }} hello you have a {{ $var }}
148
+
149
+
{% match {$foo :function option=value} {$bar :function option=value} %}
150
+
{% when a b %} {| {{$foo}} is {{$bar}} |}
151
+
{% when x y %} {| {{$foo}} is {{$bar}} |}
152
+
{% when * * %} {{ | | }}{{ $foo }} is {{ $bar }}{{ | | }}
153
+
154
+
{% input $var :function option=value %}{% local $foo = $bar :function option=value %}Hello {{ $var }}, you have a {{ $foo }}
155
+
156
+
{% match {$foo} {$bar} %}{% when foo bar %} Hello {{ $foo }} you have a {{ $var }}{% when * * %} {{ $foo }} hello you have a {{ $var }}
157
+
158
+
{% match {$foo :function option=value}{$bar :function option=value} %}{% when a b %} {| {{ $foo }} is {{ $bar }} |}{% when x y %} {| {{ $foo }} is {{ $bar }} |}{% when * * %} {{ | | }}{{ $foo }} is {{ $bar }}{{ | | }}
159
+
```
160
+
124
161
## 2. Text First, but Always Code After Code-Mode
125
162
126
163
This is @mihnita's proposal, mentioned in the 2023-10-02 call.
@@ -156,6 +193,44 @@ Hello {$user}
156
193
{match {$foo :function option=value}{$bar :function option=value}}{when a b} { {$foo} is {$bar} }{when x y} { {$foo} is {$bar} }
157
194
```
158
195
196
+
## 2a. Text First, Current Syntax for Complex Messages
197
+
198
+
Starts in text mode,
199
+
but switches to the current code-mode syntax
200
+
when the message is wrapped in `{{ }}`.
201
+
202
+
```
203
+
Hello world!
204
+
205
+
Hello {$user}
206
+
207
+
{{ input {$var :function option=value}
208
+
{Hello {$var}}
209
+
}}
210
+
211
+
{{ input {$var :function option=value}
212
+
local $foo = {$bar :function option=value}
213
+
{Hello {$var}, you have a {$foo}}
214
+
}}
215
+
216
+
{{ match {$foo} {$bar}
217
+
when foo bar {Hello {$foo} you have a {$var}}
218
+
when * * {{$foo} hello you have a {$var}}
219
+
}}
220
+
221
+
{{ match {$foo :function option=value} {$bar :function option=value}
222
+
when a b { {$foo} is {$bar} }
223
+
when x y { {$foo} is {$bar} }
224
+
when * * { {$foo} is {$bar} }
225
+
}}
226
+
227
+
{{input {$var :function option=value} local $foo = {$bar :function option=value}{Hello {$var}, you have a {$foo}}}}
228
+
229
+
{{match {$foo} {$bar} when foo bar {Hello {$foo} you have a {$var}} when * * {{$foo} hello you have a {$var}}}}
230
+
231
+
{{match {$foo :function option=value} {$bar :function option=value}when a b { {$foo} is {$bar} }when x y { {$foo} is {$bar} }when * * { {$foo} is {$bar} }}}
232
+
```
233
+
159
234
## 3. Use sigils for code mode
160
235
161
236
Try to redues the use of `{`/`}` to just expressions and placeholders instead of the three
@@ -224,6 +299,39 @@ Hello {$var}, you have a {$foo}
224
299
#match {$foo :function option=value} {$bar :function option=value}#when{a b}{{ {$foo} is {$bar} }} #when{x y}{||} {$foo} is {$bar} {||}#when{* *}{| |}{$foo} is {$bar}{| |}
225
300
```
226
301
302
+
## 3b. Double sigils for code mode
303
+
304
+
Same as 3, but the `#` sign is only special when followed by `[`,
305
+
hopefully making escaping rarely needed.
306
+
307
+
Requires `#[` to be escaped in unquoted patterns.
308
+
309
+
This variant also experiments with dropping the `when` key.
0 commit comments