3

In Sass we can combine multiple partials into single css output like

@import "scss/header";
@import "scss/footer";
@import "scss/navigation";
@import "scss/sidebar";

into

final.scss > final.css

Is there any method to do same with raw .HTML files (not .php or .asp) like

@import "header.html";
@import "scss/footer.html";
@import "scss/navigation.html";
@import "scss/sidebar.html";

into index.html

The above is just an example to explain, what I'm asking

I know I can do this using php includes but i want to know if i can with just .html files. I just want to combines files at my PC not on server.

Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852

2 Answers2

3

It's not possible in pure HTML.

To do it on the client side, you would have to use Ajax hackery with JavaScript to pull the files into the DOM, which I imagine would be pretty slow and error-prone. I don't think anybody seriously does that. There are also iframes, obviously, but again for most use cases this would be unsatisfactory.

Since you tagged your question with "rubygems": If you are using Rails, you can use partials on the server side for this purpose.

Jo Liss
  • 30,333
  • 19
  • 121
  • 170
  • I don't know ruby but i just added ruby tag to know if there is some thing like Sass for HTML, which is easy to use. I want to with raw HTML files – Jitendra Vyas May 06 '12 at 12:38
0

You can use Server Side Includes (SSI) to include other files in your .html files. In most cases you need to use the .shtml file extension for the includes to work. To learn how to implement SSI read this article from HTMLGOODIES: SSI: The Include Command

Michael Moriarty
  • 831
  • 13
  • 16