src/swipl-devel/packages/http/post.md

Repositioning HTML for CSS and javascript links {#html-post}

Modern HTML commonly uses CSS and Javascript. This requires elements in the HTML element or elements in the <body>. Unfortunately this seriously harms re-using HTML DCG rules as components as each of these components may rely on their own style sheets or JavaScript code. We added a `mailing' system to reposition and collect fragments of HTML. This is implemented by html_post//2, html_receive//1 and html_receive//2.</p> <pre><code>* [[html_post//2]] * [[html_receive//1]] * [[html_receive//2]] </code></pre> <p>The library predefines the receiver channel =head= at the end of the =head= element for all pages that write the html =head= through this library. The following code can be used anywhere inside an HTML generating rule to demand a javascript in the header:</p> <p>== js_script(URL) --&gt; html_post(head, script([ src(URL), type('text/javascript') ], [])). ==</p> <p>This mechanism is also exploited to add XML namespace (=xmlns=) declarations to the (outer) =html= element using xhml_ns//2:</p> <pre><code>* [[xhtml_ns//2]] </code></pre>



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on April 3, 2025, 5:53 p.m.