2015-06-24 29 views
2

我必须包括在clojurescript命名空间很多声明:如何在Clojurescript中减少我的ns声明的大小?

(:use-macros 
    [webapp.framework.client.coreclient 
    :only [ns-coils sql log neo4j neo4j-1 sql-1 log 
      watch-data -->ui <--data <--ui 
      watch-ui remote defn-ui-component 
      container map-many inline text 
      div img pre component h2 input 
      write-ui read-ui container 
      inline text admin ==data ==ui -->ui watch-ui <--ui 
      <--data -->data remote inputcomponent <-- 
      h1 h2 h3 h4 h5 h6 span data-view-v2 
      watch-data map-many inline text 
      container <--pos <--id session-user-id select select-debug 
      def-coils-app 
      ]]) 

有什么办法来减少这种喜欢的东西:

(:use-macros 
    [webapp.framework.client.coreclient]) 

回答

4

与clojure相比,它可以使用:参考:clojurescript中不可能。你可以在这里找到合适的答案:

Is it possible to use :refer :all in a ClojureScript :require?

然而,你可以做的是:

(:require-macros 
    [webapp.framework.client.coreclient :as client]) 

然后你就可以指任何宏观此命名空间是这样的:

(client/div ...) 
+0

我这样做的原因是,我不必每次使用“client/div”类型前缀时使用元素 – Zubair

+1

这被认为是不好的做法,因此它不是介绍给Clojurescript,它不会。 https://groups.google.com/forum/#!searchin/clojurescript/refer$20all/clojurescript/SzYK08Oduxo/p0bWhM5lftUJ –