CSI (client side includes) is a library that let you "include" an external file into an XHTML document using Ajax, without requiring any kind of server-side functionality.
While traditional includes must be used whenever possible, CSI can be handy if you have a collection of XHTML documents that must work even without being accessed from a webserver; downloadable documentation (like this) or CD-ROM containing XHTML files are a typical case.
You can see CSI used inside this document or check a sample page.
In order to use this library you need tmt_core.js, tmt_net.js and tmt_csi.js
There is only one custom attribute that must be associated with a <div> tag
| csi:src | Point to the file you want to include. It must be a text file, the extension doesn't really matters, .inc, .txt, .xml, .htm or whatever you see fit. You can use document relative or root relative paths, or even full URLs. Due to browser's security restrictions, you can't include file from a different domain. |
Include the relevant JavaScript files first:
<script type="text/javascript" src="tmt_core.js"></script>
<script type="text/javascript" src="tmt_net.js"></script>
<script type="text/javascript" src="tmt_csi.js"></script>
Then use an almost plain vanilla XHTML <div>:
<div id="includeOne" csi:src="externalfile.inc"></div>
| tmt.csi.util.load(divId, fileSrc) | You can load an external file on thy fly using this method. Or swap an existing file. See sample. |