On a wiki, they’ve got a server that can take code like {{Stats}}
and retrieve the page with that name and insert it in the current document at the position where you put that template. The technical term is transclusion and it works like a subroutine in programming. Databases have the same retrieval capabilities.
I’m trying to do transclusion with just HTML.
What I’ve got is tables that need to display differing rows of data. For example, Table A might have Options 1, 2, 3 and 5. Table B might have Options 1, 3, 4 and 6.
Previously, I just built a single page for each Table and manually added all the Options into the table. But then I started finding cases where I didn’t add the Options correctly and wound up with something like Table A showing 5 items for Option 1 and Table B showing 4 for that same Option.
So to make sure I don’t miss any data, Option 1 gets split off into its own file and that’s transcluded into the pages for Tables A and B. Provides consistency. It winds up being one main table that draws the outer border and each row in it is another table that displays the info retrieved for Option 1, Option 2, etc.
An inline frame (IFRAME) seems to be doing the transclusion properly. The issue I’m running into is that I’m having to define every single aspect of the frame: width, height, top margin, left margin, and lock out the scroll bar if the frame isn’t tall enough. Some of these commands are tagged as not being supported in HTML 5.
If I don’t try to control it down to the exact pixel and rigidly define how all aspects of each cell is supposed to be, I wind up with weird things like a blank margin above the frame that’s 5 pixels tall and 150 pixels tall below it, or trying to set a background color for the first row and it gets applied to the entire table but if I move that command into the separate file, it works correctly.
The purpose of Hypertext MARKUP Language is that you don’t have to define it down to the last pixel. If you want to, lovely, but not force you to. And even though I’ve got everything lined up correctly on my monitor in four different web browsers, as soon as I resize it down to about what a laptop’s monitor would be (the resolution is something like 1024x600 or some other oddball value), the fixed-width columns start pushing the data down below the visible area of the frame because it’s a fixed height.
The tables I had before just specified the column widths as a percentage and it resized to whatever monitor you had. Should even work on a tablet. But if I try to use percentages inside the IFRAME, one frame may not line up exactly with the one below it. It’s like it says, “Well, this table is supposed to be 100% wide, the width of the first column isn’t specified and the second column is supposed to be 7% wide, but I think I’ll make that column 22% wide instead.”
Does anyone know of a better way of doing transclusion than this method that is so fussy and so easy to break? Keep in mind the following when making recommendations:
- I’d prefer not to have to work with Javascript. We have a few websites at work we have to use that are JS version-specific and I don’t want to do anything that might interfere with them
- If it’s a style sheet, I haven’t needed to work with them before but I can learn.
- It needs to be self-contained so that it can be run off of a USB stick, so that rules out any kind of database.
- Some of the links in the web pages will open up folders containing files you copy to other locations for different procedures, and some of these file types aren’t supported by wiki software, so that rules out TiddlyWiki.
I’ll stick with the hand-coded individual web pages if I need to and just be a little more careful about where I copy and paste from, but I’d really like to find some kind of transclusion method so that there’s one file to be updated when something changes instead of several.