2011-09-19 36 views
3

我有多个html文件,这是要合并成一个单一的html文件。这些多个文件就像页眉,页脚等,这是多个文件通用的。我正在使用enlive的html-resource方法。但是,该方法插入缺少的html标签到最终文件中,我不想要。结合多个html片段文件与有活力,clojure

以下为输出地图,

({:tag :html, :attrs nil, :content (
{:tag :head, :attrs nil, :content (
{:tag :meta, :attrs {:content text/html; charset=utf-8, :http-equiv Content-Type}, :content()} 
{:tag :title, :attrs nil, :content (HewaniLife | Changing The Way You Live)} 
{:tag :link, :attrs {:href styles/main.css, :rel stylesheet, :type text/css}, :content()})} 

{:tag :body, :attrs nil, :content (
{:tag :html, :attrs nil, :content ({:tag :body, :attrs nil, :content ({:tag :div, :attrs {:id header}, :content (
{:tag :h1, :attrs nil, :content ({:tag :a, :attrs {:href index.xhtml, :id logo}, :content (
{:tag :span, :attrs {:class img-replace}, :content (hewaniLife)})})} 

{:tag :div, :attrs {:id main-nav}, :content (
{:tag :ul, :attrs nil, :content (
{:tag :li, :attrs nil, :content ({:tag :a, :attrs {:href login.xhtml, :id btn-login}, :content (
{:tag :span, :attrs {:class img-replace}, :content (Login)})})} 
{:tag :li, :attrs nil, :content ({:tag :a, :attrs {:href index.xhtml, :id btn-home}, :content (
{:tag :span, :attrs {:class img-replace}, :content (Home)})})} 
{:tag :li, :attrs nil, :content ({:tag :a, :attrs {:href search.xhtml, :id btn-search}, :content (
{:tag :span, :attrs {:class img-replace}, :content (Search)})})})})} 
{:type :comment, :data end of div#main-nav } 
{:tag :br, :attrs {:class clear-all}, :content nil})} {:type :comment, :data end of div#header })})})})} 

在这里,你可以看到嵌套的HTML标记时,我插入的文件。

是否有任何方法可以插入这些文件..?

任何人都可以使用任何其他方法..?

回答

3

您应该使用defsnippet而应该指定哪些部分是您感兴趣的。你所有的碎片甚至可以驻留在一个页面中,defsnippet会将不同的碎片抽出。

html-snippet主要用于播放repl

1

我在enlive中找到了一个名为html-snippet的方法。您可以使用它来组合多个html片段代码。