3

I have multiple html files, which is to be combined into a single html file. Those multiple files are like header, footer, etc, which are common to multiple files. I'm using enlive's html-resource method. but, that method inserting missing html tags into the final file, which I don't want.

Following is the output map,

({: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 })})})})}

Here, you can see the html tags nested when I insert the files.

Is there are any way to insert these files..?

Can anybody used any other methods..?

Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105

2 Answers2

3

You should use defsnippet rather and specify which parts are of interest to you. All your fragements can even reside in a single page and defsnippet will pluck different fragments out.

html-snippet is mainly intended for playing at the repl

cgrand
  • 7,939
  • 28
  • 32
1

I have found a method in enlive named as html-snippet. You can use it to combine multiple html fragment codes.

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105