zio-http icon indicating copy to clipboard operation
zio-http copied to clipboard

Help: need guide to use render html static page

Open ghost opened this issue 2 years ago • 5 comments

need some guide to make zio-http working with render html static page. Like: https://www.playframework.com/documentation/2.8.x/ScalaTemplates

What's the best practice to render html?

ghost avatar Jan 22 '23 23:01 ghost

Here is an old commit with a zio-http twirl example project. Beware this was made for an earlier version of zio-http, and I dont know if you can migrate it to the latest version.

https://github.com/zio/zio-http/commit/a8e9fbeb52a11f5e408c0e94e87d0ae82997a106

SoerenSilkjaer avatar Jan 25 '23 05:01 SoerenSilkjaer

The ZIO HTTP Handler.template option is decent but not documented. Another option is Scala Tags. Twirl integration works and provides a decent migration path for Play users but doesn't seem like the right choice for anyone who can choose. Overall I'd vote for improving and documenting Handler.template :)

jamesward avatar Apr 24 '23 18:04 jamesward

Twirl integration works [...] but doesn't seem like the right choice for anyone who can choose.

@jamesward What's the issue with Twirl? Any drawbacks or reasons to steer clear?

Overall I'd vote for improving and documenting Handler.template :)

Documentation aside, do you know any repo or Gist with a good example? Here's a cool example, looks solid. So, this is the route you'd recommend? Still keen on hearing about Twirl though ;)

baldram avatar Jul 15 '23 20:07 baldram

Here is where I use Handler.template https://github.com/jamesward/javadoccentral/blob/master/src/main/scala/App.scala#L29

From what I remember, the primary reason I decided not to use Twirl was due to the lack of Scala 3 language support. ie I don't think I can use braceless syntax in Twirl templates. But maybe I'm remembering things wrong.

jamesward avatar Jul 17 '23 15:07 jamesward

not to use Twirl was due to the lack of Scala 3 language support

Oh, good point! Thanks.

baldram avatar Jul 17 '23 17:07 baldram