From: vanekl on
Haris Bogdanovi� wrote:
>> (cl-who:with-html-output-to-string (str)
>> (:html
>> (:head
>> (:title "Test page"))
>> (:body
>> (dotimes (x 10)
>> (cl-who:htm
>> (:p "Text")))))).
>
> If I try to evaluate this expression then I get:
> "The variable LET is unbound."
> Where is the problem now ?


This happened to me once.
IIRC, this was a package problem. I believe I was using a package that had
not included 'common-lisp. How did you set up your package? I do my web work
in a package called 'web'.

(defpackage :web
(:use
:common-lisp
:util
:iterate
:metabang-bind
:split-sequence
:bordeaux-threads
:hunchentoot
;;:cl-who
:s-utils
:parse-number
:cube))
;; Make sure you are using the common-lisp package.

;; Depending on your implementation and what you are doing, you may also
need to do something like this:
(use-package :web :cl-user)

Is your code in the right package? If you are using Emacs and SLIME you just
need to click in the function and then look at the menu bar and it will tell
you which package the function is defined in. If that doesn't work, use the
'describe' function.

If you are using SLIME, change into your web package (whatever you call it)
by going to the REPL and typing ,!p<package-name>
That is: comma, exclamation mark, the letter 'p', and the package name where
you do your web work.

List your packages to make sure everything is loaded. You should see cl-who
and possibly hunchentoot if you are using its server. Most of the stuff
listed below you don't need.

WEB> (list-all-packages)
(#<Package "CLEAN"> #<Package "WEB"> #<Package "CUBE"> #<Package "DB">
#<Package "DBEX"> #<Package "MSORT"> #<Package "PARAM"> #<Package "MONTH">
#<Package "ORG.MAPCAR.PARSE-NUMBER"> #<Package "PARSE-NUMBER-SYSTEM">
#<Package "S-UTILS"> #<Package "CL-UTILITIES"> #<Package
"CL-UTILITIES-SYSTEM"> #<Package "HUNCHENTOOT"> #<Package "URL-REWRITE">
#<Package "CHUNGA"> #<Package "CL-BASE64"> #<Package "CL+SSL"> #<Package
"CFFI-FEATURES"> #<Package "CFFI"> #<Package "CFFI-CALLBACKS"> #<Package
"CFFI-SYS"> #<Package "BABEL"> #<Package "BABEL-ENCODINGS"> #<Package
"ALEXANDRIA.0.DEV"> #<Package "FLEXI-STREAMS"> #<Package
"TRIVIAL-GRAY-STREAMS"> #<Package "MD5"> #<Package "RFC2388"> #<Package
"TRIVIAL-BACKTRACE"> #<Package "USOCKET"> #<Package "BORDEAUX-THREADS">
#<Package "CL-BASE64-SYSTEM"> #<Package "ALEXANDRIA.SYSTEM"> #<Package
"TRIVIAL-GRAY-STREAMS-SYSTEM"> #<Package "FLEXI-STREAMS-SYSTEM"> #<Package
"CL+SSL-SYSTEM"> #<Package "MD5-SYSTEM"> #<Package "RFC2388.SYSTEM">
#<Package "TRIVIAL-BACKTRACE-SYSTEM"> #<Package "USOCKET-SYSTEM"> #<Package
"BORDEAUX-THREADS-SYSTEM"> #<Package "HUNCHENTOOT-ASD"> #<Package "CL-WHO">
#<Package "CLSQL-USER"> #<Package "CLSQL"> #<Package "CLSQL-SYS"> #<Package
"CMUCL-COMPAT"> #<Package "UFFI"> #<Package "UFFI-SYSTEM"> #<Package
"CLSQL-SYSTEM"> #<Package "UTIL"> #<Package "IT.BESE.ARNESI.MOPP%INTERNALS">
#<Package "IT.BESE.ARNESI.MOPP"> #<Package "IT.BESE.ARNESI"> #<Package
"IT.BESE.ARNESI.SYSTEM"> #<Package "CL-PPCRE"> #<Package "CL-PPCRE-ASD">
#<Package "CL-FAD-TEST"> #<Package "CL-FAD"> #<Package "ITERATE"> #<Package
"METABANG.BIND.DEVELOPER"> #<Package "METABANG.BIND"> #<Package
"ASDF-SYSTEM-CONNECTIONS"> #<Package "METABANG.BIND-SYSTEM"> #<Package
"SPLIT-SEQUENCE"> #<Package "SPLIT-SEQUENCE-SYSTEM"> #<Package "AXF">
#<Package "AXF-SYSTEM"> #<Package "SWANK-IO-PACKAGE"> #<Package "SWANK">
#<Package "SWANK-RPC"> #<Package "SWANK-MATCH"> #<Package "CROSS-REFERENCE">
#<Package "MONITOR"> #<Package "SWANK-MOP"> #<Package "SWANK-BACKEND">
#<Package "SWANK-LOADER"> #<Package "ASDF"> #<Package "ASDF-UTILITIES">
#<Package "COMMON-LISP-USER"> #<Package "OPENMCL-MOP"> #<Package
"ANSI-LOOP"> #<Package "INSPECTOR"> #<Package "X8664"> #<Package "ARCH">
#<Package "X86"> #<Package "OPENMCL-SOCKET"> #<Package "GRAY"> #<Package
"SETF"> #<Package "COMMON-LISP"> #<Package "CCL"> #<Package "KEYWORD">
#<Package "X8632"> #<Package "X86-LINUX32">)


Make sure your web package is using the packages you think it should be
using:

WEB> (package-use-list (find-package 'web))
(#<Package "COMMON-LISP"> #<Package "UTIL"> #<Package "ITERATE"> #<Package
"METABANG.BIND"> #<Package "SPLIT-SEQUENCE"> #<Package "BORDEAUX-THREADS">
#<Package "HUNCHENTOOT"> #<Package "S-UTILS"> #<Package
"ORG.MAPCAR.PARSE-NUMBER"> #<Package "CUBE">)

At the very least, you should see 'common-lisp' in your list of packages.

If you are using SLIME, do a C-c C-c in your function to make sure there
aren't any errors in your compiled code.

And that's it. It should work now.


From: Jorge Gajon on
On 2010-05-31, Haris Bogdanovi� <fbogdanovic(a)xnet.hr> wrote:
> ------------------------------------------------------
>> (defun index ()
>> (with-html-output (*standard-output* nil)
>> (:html
>> (:head
>> (:title "Test page"))
>> (:body
>> (dotimes (x 10)
>> (:htm
>> (:p "Text"))))))
>> -----------------------------------------------------------
> Page source (firefox) from this code is just:
> ------------------------------
> </body>
></html>
> --------------------------------


Hello Haris,

If you are using Hunchentoot remember that it expects the function
handling the request to return a string, for that reason you should
change `with-html-output` to `with-html-output-to-string`.

The other thing, related to CL-WHO, is that when inside the `dotimes`
form the cl-who syntax no longer applies, to re-enter cl-who syntax you
use the function `cl-who:htm`, but you were using a normal keyword
`:htm` which does not mean anything to `dotimes`.

Of course if you imported all the symbols from the cl-who package then
you only need to call it as `htm`.

I tried it quickly here on my machine and the following worked as
expected:

(defun index ()
(with-html-output-to-string (*standard-output* nil)
(:html
(:head (:title "Test page"))
(:body
(dotimes (x 10)
(htm (:p "Text")))))))


Regards,

- Jorge