Discussion:
Looks like a bug to me?
Robin Lee Powell
2008-09-29 01:03:37 UTC
Permalink
(require 'cl-who)
(use-package 'cl-who)
(let ((userid 46))
(with-html-output (*standard-output*)
(:a :id 7) (str (format nil "~%"))
(:a :id "7") (str (format nil "~%"))
(:a :id (str userid))))

I'm sure there's some better way to get newlines in the output.
Anyways, output is:

<a id='7'></a>
<a id='7'></a>
<a46 id='46'></a>

That last one is really staggeringly wrong. Is it me or the code?

-Robin
--
Lojban Reason #17: http://en.wikipedia.org/wiki/Buffalo_buffalo
Proud Supporter of the Singularity Institute - http://singinst.org/
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/
Stas Boukarev
2008-09-29 01:16:15 UTC
Permalink
On Mon, Sep 29, 2008 at 5:03 AM, Robin Lee Powell
Post by Robin Lee Powell
(require 'cl-who)
(use-package 'cl-who)
(let ((userid 46))
(with-html-output (*standard-output*)
(:a :id 7) (str (format nil "~%"))
(:a :id "7") (str (format nil "~%"))
(:a :id (str userid))))
I'm sure there's some better way to get newlines in the output.
<a id='7'></a>
<a id='7'></a>
<a46 id='46'></a>
That last one is really staggeringly wrong. Is it me or the code?
You don't need (str ...) for atrributes:

(let ((userid 46))
(with-html-output (*standard-output*)
(:a :id 7) (str (string #\Newline))
(:a :id "7") (str (string #\Newline))
(:a :id userid)))
--
With Best Regards, Stas.
Robin Lee Powell
2008-09-29 01:55:04 UTC
Permalink
Post by Stas Boukarev
On Mon, Sep 29, 2008 at 5:03 AM, Robin Lee Powell
Post by Robin Lee Powell
(require 'cl-who)
(use-package 'cl-who)
(let ((userid 46))
(with-html-output (*standard-output*)
(:a :id 7) (str (format nil "~%"))
(:a :id "7") (str (format nil "~%"))
(:a :id (str userid))))
I'm sure there's some better way to get newlines in the output.
<a id='7'></a>
<a id='7'></a>
<a46 id='46'></a>
That last one is really staggeringly wrong. Is it me or the code?
(let ((userid 46))
(with-html-output (*standard-output*)
(:a :id 7) (str (string #\Newline))
(:a :id "7") (str (string #\Newline))
(:a :id userid)))
What if I need to use format to generate the value, which is where
this use case originally came from?

(let ((userid 46))
(with-html-output (*standard-output*)
(:a :id (fmt "user-~A" userid))))

<auser-46></a>

-Robin
--
Lojban Reason #17: http://en.wikipedia.org/wiki/Buffalo_buffalo
Proud Supporter of the Singularity Institute - http://singinst.org/
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/
Richard Newman
2008-09-29 03:47:07 UTC
Permalink
Post by Robin Lee Powell
What if I need to use format to generate the value, which is where
this use case originally came from?
(let ((userid 46))
(with-html-output (*standard-output*)
(:a :id (fmt "user-~A" userid))))
(:a :id (format nil "user-~A" userid))

Attributes can contain any Lisp expression.

If you want to make sure the user ID is escaped:

(:a :id (escape-string-minimal-plus-quotes
(format nil "user-~A" userid)))

Loading...