ailisp / flute

A beautiful, easilly composable HTML5 generation library in Common Lisp
64 stars 7 forks source link

Is there a way to include boolean values in a tag? #11

Open may opened 1 year ago

may commented 1 year ago

For example, if I want to produce the following output:

<script defer data-domain="example.com" src="example.com/script.js"></script>

@ailisp How do I include the defer boolean? (HTML treats it as a boolean; if it exists it's true, else false. You can't assign it a value like defer=true.)

The closest I've come is this, but I haven't found a way to include defer:

(script :data-domain "example.com" :src "example.com/script.js")

Thanks so much for making a great library! Hopefully I just am not figuring this out and it's a quick fix that isn't in the documentation.

may commented 1 year ago

If anyone else runs into this, I found a workaround:

  1. Don't escape HTML.
  2. Provide a string with the output you want.

Eg:

(setq *escape-html* :attr)
...
(head "<script defer data-domain=\"example.com\" src=\"example.com\"></script>")