我正在为我的网页添加自定义backbone.js scrips,它需要在页面的末尾,
我已经查看了将脚本添加到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>
答案 0 :(得分:1)
刚刚意识到它像骗子一样简单: 我的解决方案是非惯用的,我添加了大量的印刷品,以了解引擎盖下的内容;一旦我发现变换器的[: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))))