Writing HTML with Racket and X-Expressions (2019)
21–30 of 30 posts
Re: Writing HTML with Racket and X-Expressions (2019)
#22The idea is right, but all the 'quoting and explicit list calls make this super awkward. If you're going to do it, do it right... use macros. Of course, then you'd end up something that looks a lot like Haml ( http://haml.info/ ) with parens everywhere.
Re: Writing HTML with Racket and X-Expressions (2019)
#23Something similar (and less of a parentheses hell) is Scalatags by the amazingly prolific scala programmer lihaoyi. The good things about Scalatags is that the same code can be used both in the backend and in the frontend. (I don't use scala on the backend anymore but Scala.js is really good!)
Re: Writing HTML with Racket and X-Expressions (2019)
#24Re: Writing HTML with Racket and X-Expressions (2019)
#25 element html {
element body {
element div {
attribute id {"main"},
"foo bar!",
1 to 15,
element footer { "this is the footer" }
}
}
}
foo bar! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15this is the footer
1: https://www.w3.org/TR/xquery-31/#id-computedConstructorsRe: Writing HTML with Racket and X-Expressions (2019)
#26Re: Writing HTML with Racket and X-Expressions (2019)
#27Can someone explain the difference between an S-expression and an X-expression? Even after reading the blog post I'm not following, seem like the same thing to me.
Re: Writing HTML with Racket and X-Expressions (2019)
#28I wrote my book[0] in Racket and the experience was quite good. The idea of manipulating html as X-expressions is great and it allows you to easily implement markup for sidenotes for instance. [0]: https://whycryptocurrencies.com/
Re: Writing HTML with Racket and X-Expressions (2019)
#29Can someone explain the difference between an S-expression and an X-expression? Even after reading the blog post I'm not following, seem like the same thing to me.
[1] https://docs.racket-lang.org/teachpack/2htdpbatch-io.html?q=...
Re: Writing HTML with Racket and X-Expressions (2019)
#30Can someone explain the difference between an S-expression and an X-expression? Even after reading the blog post I'm not following, seem like the same thing to me.
Started dabling recently so Im not an expert on the subject, but from my understanding, Racket represents XML data as an X-expression. On the other hand symbolic expressions aka s-expressions are the syntactic elements of the Lisp programming language. Both programs and data are represented as s-expressions: an s-expression may be either an atom or a list. So x-expressions relate to XML
There are other solutions, such as representing HTML as structures (often called records in other languages). This is what I prefer - this allows a little static checking. (See `scribble/html` or `urlang/html`).
Others prefer to work with `templates`.
My point got lost: There is more than one "Racket way" of working with html.