Jens Axel Søgaard wrote on 2/4/19 3:38 PM:
(define (html-flash-card)
; style: "border:1px solid black"
@div[class: "col-md-6" ]{
@div[id: "flash-card-content"]{
@div[id: "flash-card-question-container"]{
@div[id: "flash-card-question"]{
@h2{Flash Card}
@p{The name of the mathematical exponentiation operator?}
@p{ $$ c = \sqrt{a^2+b^2} $$}}}
@html-answer-box[]}})
This example looks good, and I like the at-reader. An alternative, for
people who love parentheses, and want some to optimize a little more for
static parts at compile time, here's an approximate (untested) way using
`html-template`:
(define (example-html-flash-card-1)
(html-template
(div (@ (class "col-md-6"))
(div (@ (id "flash-card-content"))
(div (@ (id "flash-card-question-container"))
(div (@ (id "flash-card-question"))
(h2 "Example Flash Card")
(p "The name of the mathematical exponentiation
operator?")
(p (% $$ c = \sqrt{a^2+b^2} $$))))
(%write (html-answer-box))))))
Or, another way to use `html-template` is to define your own
application-specific syntax forms that expand to it. So, if you're
doing flashcards, you might define `flash-card` syntax that you can use
like:
(flash-card
#:title "Example Flash Card"
(p "The name of the mathematical exponentiation operator?")
(p (math "c = \sqrt{a^2+b^2}")))
See "https://www.neilvandyke.org/racket/html-template/" for an example
of what happens at compile time (specifically, syntax transformation
time). It uses only Racket port-writing, and can be combined with other
port-writing procedures -- it uses no special Racket buffer management,
nor opportunities with any HTTP server/fronting, nor lower-level OS
facilities
(Sorry the code of `html-template` itself is more scary than it now has
to be. I've done some unreleased work atop this package, for an
unfunded startup, but no more work on this package itself.)
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.