1

Is it possible to reuse HTML tags across multiple files, headers and footers for example? Placing them in separate files adds an extra HTTP request, that I'd like to avoid.

I don't want to replicate minor changes in headers and footers across every html file every time a change request comes along.

HyderA
  • 20,651
  • 42
  • 112
  • 180
  • Is there a toolkit that does that for you. Managing HTML across multiple files similar to Dreamweaver's templates? – HyderA Aug 22 '09 at 23:23
  • If Dreamweaver can do that, why don't you simply use it? – Michael Borgwardt Aug 22 '09 at 23:31
  • indeed very interesting idea. – Mohamed Aug 22 '09 at 23:32
  • asp.net webforms is not really html but ultimately the controls get rendered as HTML..in its control form they are nothing but objects. – Perpetualcoder Aug 22 '09 at 23:33
  • @Michael, Dreamweaver requires use of Dreamweaver to get templates to work. We have gone through a lot of trouble allowing our developers to use whatever environment they feel comfortable working in. I wouldn't want to force it on them. I'd rather develop an in-house tool kit, that acts as a builder. – HyderA Aug 23 '09 at 00:03
  • This question is asking for mutually exclusive requirements. OO is designed to improve programmer performance but is not considered to improve machine performance. – Sam Hobbs Apr 01 '19 at 20:57

9 Answers9

13

HTML is not a programming language - it's a markup language. You don't do object-oriented HTML because it isn't object based. This is the whole purpose of a server-side language, so you can make include files and use them in your server-side application.

If you have Apache however, you can use server-side includes which don't require a programming language such as PHP, but it's less flexible:

<!--#include virtual="/footer.html" -->
meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
  • You can do server side includes with IIS also. – Kevin LaBranche Aug 22 '09 at 23:29
  • I know about server side includes. What I want to do is this. The files can be scattered during development. But I when I'm ready to release, a toolkit should compile the included files into a single html file. – HyderA Aug 22 '09 at 23:33
  • 1
    I'm confused - WHY can't you use a server-side language? If you're relying on something like php includes it wouldn't include each file as a separate HTTP request, it all becomes one HTTP request for the document you are feeding ( plus media resources like js/css ). – meder omuraliev Aug 22 '09 at 23:34
  • We're using Java as our backend, the project manager is in no mood of listening to another server deployment(PHP). We use Ajax requests to fetch data, not JSP. So all are files front-facing files are HTTP extensions. – HyderA Aug 22 '09 at 23:53
2

First, HTML isn't even a programming language, so it's impossible to have "Object-oriented" HTML.

Placing them in separate files adds an extra HTTP request, that I'd like to avoid.

If this is the reason for your "without server side code" requirement, then you are mistaken - the client does not fetch the templates that make up a page separately; the server side code will return a single HTML page to the client.

If, on the other hand, you don't have the option to run any server-side code at all and have to make do with static HTML pages, then there's only two options I can think of: iframes (which do result in separate HTTP requests, of course), or some sort of tool that basically runs the equivalent of server-side code to embed your reused templates everywhere and spits out the result to be uploaded to the server. You can have this effect by running a PHP/Apache-with-SSI/JSP/Whatever server on your development machine and using wget to make a static snapshot of the pages.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
  • No, that's not my concern for avoiding server side code. We already have server side code and we use AJAX to fetch it. I curse you for mentioning the i word! Still, another HTTP request. Our application is inherently quite complex, so when I say I'm worried about HTTP requests, I mean at least half a dozen of 'em in each page. And I don't like relying of cache. – HyderA Aug 22 '09 at 23:56
1

What I want to do is this. The files can be scattered during development. But I when I'm ready to release, a toolkit should compile the included files into a single html file.

You can use a template language/engine, such as jinja2.

You can layout files in a certain hierarchy, and have templates inherit from other templates, and include other templates, and define reusable macros (closest thing to what you referred to as "reusable tags").

hasen
  • 161,647
  • 65
  • 194
  • 231
1

What I want to do is this. The files can be scattered during development. But I when I'm ready to release, a toolkit should compile the included files into a single html file

I know this is late, but CodeKit's .kit language lets you do exactly what you were saying.

http://incident57.com/codekit/help.php

coulbourne
  • 489
  • 1
  • 8
  • 16
1

I think the language you've chosen in your question (object oriented HTML) is actually masking the real issue you have here...

What I want to do is this. The files can be scattered during development. But I when I'm ready to release, a toolkit should compile the included files into a single html file.

This sounds like a job for a preprocessor, I don't believe it has anything to do with your webserver or server side technology, as this is a step which would happen before deployment.

There's a number of text pre-processors available eg M4 - hell you could even use the C compiler pre-processor if you wanted. A quick google reveals that there are specialised pre-processors for HTML as well....

Automatic file inclusion, automatic escaping, and whatnot that can be done with automatically inserted headers and footers, chosen based on path patterns.

Seems to fit the bill?

MattDavey
  • 8,897
  • 3
  • 31
  • 54
0

Sure . But these would have to be separate ajax calls form the client . There are lot of javascript mvc frameworks like that do that .

Community
  • 1
  • 1
Surya
  • 4,922
  • 8
  • 41
  • 54
0

If you want to have include files during development, then compile them into free-standing HTML files, you could do that by spidering your development server with wget: whatever server-side technology you use will combine the files and return the HTML, which wget will saves as one file.

AmbroseChapel
  • 11,957
  • 7
  • 46
  • 68
0

You can do this.

I just released a mature framework called Hypertag that is, in fact, Object Oriented HTML. It is entirely client-side, in continuous development, and allows for very interesting, yet HTML-compatible, advanced solutions for logic and layout.

See http://hypertag.io for more.

0

As everithing is object over the technology but not directly, indirectly interacting with the object that are created at different level as per security implementation.