I am trying to do something very straightforward... emit some HTML content with a link to my style sheet, as explained here, on the SWI-Prolog page: Repositioning HTML for CSS and JavaScript links:
http://www.swi-prolog.org/pldoc/man?section=html-post
The only included library is:
:- use_module(library(http/html_write)).
I have my generic dcg rule for outputting the CSS content, exactly as per the example:
css(URL) -->
html_post(css,
link([ type('text/css'),
rel('stylesheet'),
href(URL)
])).
Then the example says 'Next we insert the unique CSS links...', but the example given doesn't supply a parameter for the unique URL to be inserted. So I'm guessing at this:
reply_html_page([title('mytitle'), \html_receive(css('/my.css'))],
[
div([id='mydivid'], 'divstuff..'
)
]).
But running it does not output the CSS content as expected... The title gets processed, but the CSS link is missing.
Content-type: text/html; charset=UTF-8
<!DOCTYPE html>
<html>
<head>
<title>mytitle</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="mydivid">divstuff..</div>
</body>
</html>
Looking at the trace, the CSS dcg rule never gets executed (version 6.6.4).
Perhaps the solution needs to include html_receive/2(+Id, :Handler), rather than /1, but there are no simple copy/paste/run examples which would explain its usage. The code snippet for html_receive/2 contains html_post.