The L-Space Web: Developers

Local Macrodefs

When creating pages for The L-Space Web, you may find that you are using the same piece of HTML again and again. By creating a macro for this HTML, you can save yourself a great deal of time and effort.

Example: created for the afparty section

m4_dnl $1 = section of afparty m4_dnl Combines _X_DOCTYPE(),_X_META and _X_CSS with all relevant info hardcoded
_X_META(´Discworld Terry Pratchett L-Space Lspace afp party afparty', The 10th birthday celebrations of, ´The L-Space Librarians',´iso-8859-1')
<title>The L-Space Web: Afparty -- $1</title>
_X_CSS(´Default Stylesheet', ´_CSS/afparty-style.css')

<div class="smaller"><em>The L-Space Web: Afparty</em><hr /></div>
<div class="center">
<h1 class="blue">Afparty -- $1</h1>
<hr />

As you can see from the example above, it is possible to reduce large pieces of code down to one small macro definition call, i.e. _AFPARTY_MONTH_HEADER(August Meets). This local macro was especially useful for creating pages that list the afparty meets by month.

This is also a good example of how to create a macro that calls a section-specific style sheet.

To create your own macrodefs file, navigate to your local copy of L-Space, and create a file a plain text file named macrodefs.m4. Now you need to define your macros. See the example above for pointers on this.

Note that the information to be expanded by the macro must begin with an acute accent/reverse apostrophe ( ´ - ANSI Character 180) and end with a normal apostrophe ( ' - ANSI Character 39)

It is also advisable to comment each macro definition to explain it's usage and indicate, at the top of the file, in what section of L-Space Web this local macrodef file is to be used.

If you are maintaining a directory with associated sub-directories, you may need to use a local macro within the main directory and its sub-directories as well. Rather than creating/copying the same local macrodefs file into each sub-directory, you can, by a simple change to the local makefiles, call from just one local macrodef.m4.

Locate each copy of makefile within the sub-directories involved. Redefine the variable "LOCALMACRODEFS" to the value "../macrodefs.m4". This allows the local macrodef in the topmost directory to be called by all pages in the immediate sub-directories.

Note: If you use ' (apostrophe) or ´ (acute accent/reverse apostrophe) within the text of your macro definition:

Example: Terry's or Terry´s

quote these characters as HTML ampersand-entities (&#39; or &#180;) otherwise make will fail to complete successfully

This section of L-Space is maintained by The L-Space Librarians

The L-Space Web is a creation of The L-Space Librarians
This mirror site is maintained by The L-Space Librarians