Hacker News new | ask | show | jobs
by librasteve 632 days ago
I have been working on a raku module (HTML::Functional) to do this, as with the OP the main motivation is for me to be able to declutter my own projects, so not widely used, but yes OSS.

Here is an "Elm-like" example from https://elmprogramming.com/building-a-simple-page-in-elm.htm... coded in raku. HTMX is a great lever to put the code on the server - thus Go, Raku, whatever.

  use HTML::Functional;

  my $body = body [
    div( :class<jumbotron>, [
      h1("Welcome to Dunder Mifflin!"),
      p  "Dunder Mifflin Inc. (stock symbol{strong 'DMI'})\n" ~
          q:to/END/;
          is a micro-cap regional paper and office
          supply distributor with an emphasis on servicing
          small-business clients.
          END
    ]),

    p :hx-get<https://v2.jokeapi.dev/joke/Any?format=txt&safe-mode>,
      "Click Me",
  ];

From the module synopsis which means some of the capabilities of the Raku Quoting Slang are in play ... https://raku.land/zef:librasteve/HTML::Functional. Raku functions only need parens for disambiguation btw. Named attrs can use the :name<value> syntax which imo is the tidiest.
1 comments

Raku is such a great language! It’s a shame it doesn’t get the attention it deserves. Thanks for sharing!