【问题标题】:Enlive templates - how to append script to end of the page启用模板 - 如何将脚本附加到页面末尾
【发布时间】:2014-05-27 05:34:20
【问题描述】:

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

我已经查看了将脚本添加到 html 头部的解决方案,如下所述:Enlive templates – add to head section

很遗憾,我需要在页面底部添加脚本。

<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>

【问题讨论】:

    标签: clojure enlive


    【解决方案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))))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 2023-03-15
      • 2020-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-02
      相关资源
      最近更新 更多