1

我正在向我的页面添加自定义主干.js 脚本,它需要位于页面末尾,

我已经查看了将脚本添加到 html 头部的解决方案,如下所述:Enlive 模板 – 添加到头部部分

不幸的是,我需要在页面底部添加脚本。

<html>
   <head><!-- all the normal css and js scripts--></head> 
   <body> 
      <div> <!-- html content that will be used by my scripts --> </div>
      <!-- this is where i want to append custom javascripts  -->

  </body>

</html>
4

1 回答 1

1

刚刚意识到它就像 conj 一样简单:我的解决方案是非惯用的,我添加了很多打印来了解引擎盖下的内容;一旦我发现变压器的 [:body] 输入是一个向量,conj 就成为一个明显的解决方案,

(html/sniptest "<html><body><header class=\"some_class\">Header Content</header><footer>sddsd</footer></body></html>"
    [:body] (fn [html-source]
              (let [conts (:content html-source)
                    newstuff  {:tag :script
                               :attrs {:src "../javascripts/foundation/foundation2.forms.js"}
                               :content []}
                    _  (pprint conts)
                    _  (print (class  conts))
                    conts2 (conj conts newstuff )]
                (assoc html-source :content conts2))))
于 2014-05-25T15:10:49.167 回答