Index < Previous     Next >
The standard macro library wpplib [ ^ ]
Starting from wpp 2.13 I've slowly defined some extensions for wpp.
The INLINE, EVAL and SYSTEM functionality allows to write down complex features without hacking wpp code. My basic idea was to move every built-in macro outside wpp in the cleaner way possible for keeping the preprocessor as simple as possible.
A simple content managing system oriented macro library [ ^ ]
I've started developing this library for collecting some useful macros I've written mainly in order to track down the chaos of url checking and relativizing. The main concept is that when passing and url to a wpplib macro it can be relative (without the leading '/') or "absolute" (immagine that your website url start the output directory level).
Source raw/section2/index.raw
...
<!-- absoulte path -->
@RURL("/images/null.gif")@
...
<!-- relative path -->
@RURL("images/pp_by_wpp.gif")@
...
Output html/section2/index.html
...
<!-- absoulte path -->
../images/null.gif
...
<!-- relative path -->
images/pp_by_wpp.gif
...
Absolute urls will be "magically" casted into relative ones that can be used safely even if the generated documents wouldn't being placed at the root of a website.
The main advantage is that typing "/images/null.gif" it's safer than "../../images/null.gif", suppose you're moving to a different level one or more files holding relative references in the latter form: you have to check each of them and edit by hand everything.
The relativizing approach it's somehow useful even when you move the referenced file, this time you have to edit the sources but you know the original absoulte path and the final one: writing a search and replace command line script with your favourite tool (perl, sed, awk) it's really easy!

Anyway you can call any wpplib macros with a complete url.
Actually it's simply returned as is but in the near future will be (optionally) able to check even complete urls while generating documents.

Using wpplib [ ^ ]
Setup your config file in order to include the directory where 'wpplib.tmpl' is installed. For example suppose you have copied it into '/usr/share/wpp':
config
...
@DEFAULT_TMPLPATH=templates:/usr/share/wpp@
...
Or calling wpp by using the -D command line switch:
wpp -D DEFAULT_TMPLPATH=templates:/usr/share/wpp -
Once you've set up the template paths you can include safely wpplib.
Source
...
@INCLUDE wpplib@
...
The macros exported by wpplib [ ^ ]
Macro Description
@WPPLIB_VERSION()@
Returns wpplib version.
@FIXME()@
@FIXME(TEXT)@
A simple macro that creates a red bordered box containing FIXME and the optional TEXT message.
@NULL()@
@NULL(SIZE)@
@NULL(WIDTH, HEIGHT)@
It's used to wrap a 1x1 pixels transparent gif in order to expand to the wanted size (useful for filling spaces or forcing table sizes).
The first version generates an 1x1 image, the second version generates a square SIZExSIZE transparent image.
The image is by default the relativized url for '/images/null.gif', you can customize it by setting the variable @NULL_IMAGE@ with the proper url.
@RURL(PATH)@
@RURL(PATH, NODEPS)@
Return the relativized path.
If NODEPS is defined (not an empty string) dependencies will not be generated.

Note: RURL it's now a built-in macro since it's user internally by wpp for the other built-in macros.

@RLINK(URL)@
@RLINK(TEXT, URL)@
@RLINK(TEXT, URL, TARGET)@
@RLINK(TEXT, URL, TARGET, EXTRA)@
@RLINK(TEXT, URL, TARGET, EXTRA, NODEPS)@
Generates an "a href" tag. The EXTRA parameter is used for inserting other parameters into the first "a" part.
The URL, if it's a path, is relativized.
If NODEPS is defined (not an empty string) dependencies will not be generated.
@RIMAGE(IMG)@
@RIMAGE(IMG, ALT)@
@RIMAGE(IMG, ALT, EXTRA)@
@RIMAGE(IMG, ALT, EXTRA, URL)@
@RIMAGE(IMG, ALT, EXTRA, URL, NOURLDEP)@
Generates an "img" tag. The EXTRA parameter is used for inserting other parameters.
The IMG, if it's a path, is relativized.
@RCSS_LINK(CSSFILE)@
@RCSS_LINK(CSSFILE, MEDIA)@
@RCSS_STYLE(CSSFILE)@
@RCSS_STYLE(CSSFILE, MEDIA)@
Include a style sheet file reference using a "link" or a "style" tag.
^ Top < Previous     Next >