1:- module(boxes, [
    2		  abox//3
    3		 ]).    4
    5:- use_module(library(http/html_write)).    6
    7/*
    8> Only problem is, if, in the contents, I include the encapsulation
    9> escape \,  I run into module problems. Neither  \@(faq_entry,
   10> indexpage) nor \indexpage:faq_entry are recognized as \term
   11> encapsulation.
   12>
   13> Is there a way to force it to be recognized? I guess I could force
   14> the caller to call html//1 every time, but that seems an unneccessary
   15> burden on the caller.
   16
   17
   18The problem is that \ and : have the wrong priority, and the term
   19becomes:
   20
   211 ?- display(\a:b).
   22:(\(a),b)
   23true.
   24
   25So, you should write
   26
   27    \(indexpage:faq_entry(...))
   28
   29>> That said, what is wrong with importing indexpage into the current
   30>> context?  That also makes the dependency much more explicit.
   31>
   32> The only problem with importing it is that you now have a utility
   33> module that has to explicitly list all it's users.
   34>
   35> abox is a bit of code that lays out a widget that might appear
   36> anywhere in the site. This page
   37> http://hhpvirtual.net/viewer/splash.html is a mockup for the webapp
   38> I'm building. The roundrect 'badges' scattered around are what abox
   39> generates. In design pattern terms, I'm implementing the 'library'
   40> pattern. I have a library of bits of \foo encapsulation where I'm
   41> really saying 'I wish HTML had a foo tag'.  So having a list of every
   42> page on the site at the top of layout.pl (the library file) seems
   43> wrong.
   44
   45You must declare your utility predicates as meta-predicates.  There
   46is a helper directive :- html_meta
   47http://www.swi-prolog.org/pldoc/doc_for?object=html_write:html_meta/1
   48that does this for you and provides the cross-referencer and PceEmacs
   49with the info to understand your code.
   50
   51> Or have I been programming in Java too much and have a brain
   52> infection?
   53
   54I don't know.  It is dangerous though :-)
   55
   56    Cheers --- Jan
   57*/
   58
   59:- html_meta  abox(+, +, html, ?, ?).
 abox(+ClassAdditions:atom, +Title:atom, +Contents:termerized_html)// is det
Create a round corner rect box with a title area above and contents below
   68abox(ClassAdditions, Title, Contents) -->
   69	html([
   70	    div([class='abox header ' + ClassAdditions], p(Title)),
   71	    div([class='abox content ' + ClassAdditions], Contents)
   72	     ])