I was just huddling with @pez about various things and templating came up, and he showed me Selmer and asked how that might work in YS. A Selmer example:
{% for item in items %}
- {{item}}
{% endfor %}
A YS program doing template interpolation:
!YS-v0
items =: read('/usr/share/dict/words'):words:shuffle.take(10)
say: |
$(for([item items]
" - $item
"
).join("\n"))
giving:
$ ys template.ys
- ply's
- nontechnical
- Jinny's
- evictions
- lawbreaker
- masterstrokes
- Amparo's
- teed
- souse's
- backsliding
Or slightly more interesting:
$ cat template2.ys
!YS-v0
words =: read("/usr/share/dict/words")
.std/words()
.filter(/^[a-z]+$/)
defn main(n=10):
say: |
$((1 .. n).map(li):join:trimr)
defn li(num): |2
$num) $(words:rand-nth)
$ ys template2.ys 7
- 1) mother
- 2) peace
- 3) roar
- 4) feta
- 5) shorts
- 6) calves
- 7) retail