This is my first question here, so please excuse mistakes.
I want to generate dynamic HTML from a list in Prolog. For each question I want to generate a p-tag with this question.
question(1, 'First Question').
question(2, 'Second Question').
get_quest( Q ) :- question( _, Q ).
index(_Request) :-
get_quest( Q ),
reply_html_page(
[
title('Dynamic HTML')
],
[
h1('Questions'),
p( Q )
]
).
I know this can't work, but I can't find the right solution.
UPDATE
here is my implementation of the code. thank you all for help
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_error)).
:- use_module(library(http/html_write)).
server(Port) :-
http_server( http_dispatch, [ port(Port) ]).
:- http_handler( root(.), index, [] ).
:- encoding( utf8 ).
get_quest( Q ) :- question( _, Q ).
index(_Request) :-
reply_html_page(
[
title('Questions')
],
[
h1('Dynamic HTML')
|\tables
]
).
tables -->
{ tables( Ls ) },
html( [ div( ul( Ls ) )]).
tables( Ls ) :-
findall( li( Q ), get_quest( Q ), Ls ).