announcements

Project/library announcements ONLY - use threaded replies for discussions. Do not cross post here from other channels. Consider #events or #news-and-articles for other announcements.
seancorfield 2021-05-06T00:02:39.133500Z

I was running into problems with it in our multi-artifact monorepo at times and I just sort of got tired of working around it. I also wasn’t 100% sure I was doing it correctly, conditionally, for use with GraalVM-native so I figured I should just remove the “at times”/uncertainty and be done with it. Lots of next.jdbc users seem to want the snake/kebab conversions anyway (and it’s not like next.jdbc doesn’t already depend on other libs — I’m a bit surprised the java.data dependency/code doesn’t cause GraalVM-native issues…?).

borkdude 2021-05-06T19:30:58.137300Z

New Selmer release! 🎉. Selmer is a powerful templating engine for Clojure and is now written in 100% pure Clojure with no external dependencies. https://github.com/yogthos/Selmer 1.12.38 - made JSON dependency pluggable, remove hard dependency on cheshire 1.12.36 - improved default pretty printing of the context map using debug tag - allow whitespace in filter: {{ foo | default:bar }} 1.12.35 - made json-html dependency optional, removed commons-codec dependency Thanks @yogthos for the awesome library and being open to receive these enhancements. Selmer (1.12.35) is now part of #babashka (version 0.3.8, bb will bump to Selmer 1.12.38 soon).

1229🎉
roklenarcic 2021-05-07T07:02:19.148700Z

Main thing missing from Selmer compared to python’s Jinja 2 (which has similar syntax) is whitespace control. If you put tags like {% if %} on their own line, you’ll get an empty line in the output. and you cannot say {%- if -%} . It makes writing some whitespace sensitive markup like YAML really hard. You basically need to keep the if, else, endif to the same line which can be a real mess.

borkdude 2021-05-07T07:03:48.149300Z

Maybe you can post an issue about this?

roklenarcic 2021-05-07T07:05:39.149500Z

https://github.com/yogthos/Selmer/issues/115

roklenarcic 2021-05-07T07:05:50.149800Z

5 years old 🙂

borkdude 2021-05-07T07:07:57.150400Z

@yogthos ?

borkdude 2021-05-07T07:09:12.151300Z

Ah it seems he’s open to the contribution so what are people waiting for :)

roklenarcic 2021-05-07T07:10:05.151500Z

Hehe, I think the change is pretty large, as it fundamentally changes the processing, because you might have to remove content before the tag based on the tag itself

borkdude 2021-05-07T07:11:19.152100Z

Has anyone tried?

roklenarcic 2021-05-07T07:12:10.152300Z

Haven’t seen it 🙂

roklenarcic 2021-05-07T07:12:54.152500Z

On the second thought, it doesn’t change the render, it changes the template parse, as you can already cut the appropriate whitespace when you parse the template

borkdude 2021-05-07T07:14:16.154200Z

I made a change to allowing whitespace in filters yesterday. It was doable. Don’t know about this change, but seems like a nice challenge

Karol Wójcik 2021-05-07T09:33:38.155200Z

Thank you so much @borkdude! Great release!

yogthos 2021-05-07T12:58:09.156500Z

and yeah white space control is a bit of a rabbit hole, the trickiest part is that you have to be able to look ahead to the end of the line to see if it's just space, and the reader doesn't support unbounded look ahead

yogthos 2021-05-07T12:58:40.156800Z

so you'd have to make a version of a reader that's able to scan to see if the next non space character is a new line

borkdude 2021-05-07T13:03:56.157Z

@yogthos isn't this just about ignoring all whitespace between tags? I think this can be done using a flag? when you encounter the "signal" to ignore whitepace, you set the flag, then the reader ignores all blank TextNodes, until it finds the next "signal" to ignore whitespace?

yogthos 2021-05-07T13:04:53.157200Z

oh I guess there are a few different cases here, one I was thinking of is if you have a tag on an empty line, and you want to remove that line after

yogthos 2021-05-07T13:06:20.157400Z

space inside the tag is easier to control

borkdude 2021-05-07T13:10:19.157700Z

you mean it like this right? {% if foo} <inside tag> \n\n {{dude}} <inside tag> \n\n{% endif}

borkdude 2021-05-07T13:10:46.157900Z

from the issue I was interpreting it like that: people would like to spread the expression over multiple lines, while not rendering multiple lines

borkdude 2021-05-07T13:10:57.158100Z

but it would be good to double check

yogthos 2021-05-07T14:30:44.158900Z

oh I guess yeah that could be another use case 🙂

roklenarcic 2021-05-10T18:32:34.190Z

There’s basically 2 cases: {% tag -%} is easy you basically start droping whitespace after the tag until you find something that is not a tag

roklenarcic 2021-05-10T18:33:55.190300Z

The other case is {%- tag %} which you can solve if you maintain the index of the last non-whitespace character you’ve encountered, then when you hit a tag like that you can simply set the length on the StringBuilder back to that index before you proceed with .setLength

borkdude 2021-05-10T18:34:30.190500Z

ah is that how it works

borkdude 2021-05-10T18:34:43.190700Z

@roklenarcic I have a branch which is very close to this, I think

roklenarcic 2021-05-10T18:35:00.190900Z

That;s how I would approach it at least

borkdude 2021-05-10T18:35:54.191100Z

but I discussed this syntax with yogthos and it didn't feel compose-able to me. we bounced around some ideas and came up with e.g. {% tag(trim) %}, a bit like [:tag {:trim true} ...] in hiccup

borkdude 2021-05-10T18:36:55.191300Z

but I guess we can meet people where they are coming from jinja etc

borkdude 2021-05-10T18:37:36.191500Z

@roklenarcic Feel free to try out this branch: https://github.com/borkdude/Selmer/tree/whitespace-control

roklenarcic 2021-05-10T18:38:52.191900Z

You should think carefully if your variant enables everything that you get when you have 3 different variants available: {%- tag %} , {% tag -%} and {%- tag -%} I assume your solution is only 1 of these 3

borkdude 2021-05-10T18:40:36.192100Z

I was mostly working on this from the angle of "is it possible", I wasn't actually interested in any specific solution