This module manages rendering answers using alternative vizualizations.
The idea is that a specific context uses zero or more rendering
modules. These rendering modules provide an alternative HTML
representation for the target term. If multiple possible renderings are
found, a <div class="render-multi">
element is generated that
contains the alternative renderings. The jQuery plugin renderMulti
,
defined in answer.js
adds the behaviour to change rendering to the
generated div.
The user can import rendering schemes into the current context using the
directive below. Spec is either an atom or string, making the system
look for render(Spec)
, or it is a (single) file specification that can
be used for use_module/1.
:- use_rendering(Spec).
A rendering module is a Prolog module that defines the non-terminal term_rendering//3, which will be called as below. Term is the (non-var) term that must be rendered, Vars is a list of variable names bound to this term and Options is a list of write options that would normally be passed to write_term/3. The grammar is executed by library(http/html_write) and must generate compatible tokens (which means it must call html//1 to generate HTML tokens).
phrase(Renderer:term_rendering(Term, Vars, Options), Tokens)
use_rendering(FileOrID,
[])
.