0

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?

Marwan Ansari
  • 123
  • 1
  • 10
wang kai
  • 1,673
  • 3
  • 12
  • 21
  • `org.clojure/clojure "1.8.0"` and `compojure "1.5.2"` are pretty old releases. Try to use the most recent ones. – akond Jan 25 '19 at 03:55
  • Thanks.I don't know why "lein new compojure-app" will give me clojure 1.8 and compojure 1.5 by default,I have use clojure 1.10 and compojure 1.6.1 but the error is the same – wang kai Jan 25 '19 at 05:38

1 Answers1

0

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)))
Denis Fuenzalida
  • 3,271
  • 1
  • 17
  • 22