I use "lein new compojure-app" to create a web project, hiccup has been already imported in project.clj:
:dependencies [[org.clojure/clojure "1.8.0"]
[compojure "1.5.2"]
[hiccup "1.0.5"]
and I can see the jar file
I use intellij for ide,in home.clj:
(ns ansible.routes.home
(:require [compojure.core :refer :all]
[ansible.views.layout :as layout]
[hiccup.form :refer :all]
))
but when write:
(form-to [ :post "/"]
intellij tells me form-to can't be resolved
, if I use this:
[hiccup.form :as hf]
then write
(hf/
intellij tells me I can use function:group,input-filed,make-id,make-name,with-group,but no form-to,but form-to is a function in package hiccup.form
How do I fix this?
Generally, using :require
with :refer :all
is considered bad form, because it may shadow some functions without you noticing.
Check if any of the other namespaces you require in home.clj
already has a function called form-to
. Try using something like:
(ns myapp.routes.home
(:require [compojure.core :as cc :refer [defroutes GET]]
[myapp.views.layout :as layout]
[hiccup.form :as hf]))
(defn home []
(layout/common [:h1 "Hello World!"]))
(defroutes home-routes
(GET "/" [] (home)))