Skip to main content

module StaticSite

rascal-0.28.2

Usage

import demo::vis::StaticSite;

Dependencies

import lang::html::IO;

Synopsis

Demonstrates HTML generation and viewing in Rascal

Description

In the current module we have a function table which transforms any binary relation into an HTML table:


module demo::vis::StaticSite

import lang::html::IO;


HTMLElement table(rel[&T, &U] r)
= table([
tr([
td([text("<a>")]),
td([text("<b>")])
])
| <a, b> <- r
]);

When we try this out on the commandline, the REPL will pop-up a browser window such that we can visualize the result:

rascal>import demo::vis::StaticSite;
ok
rascal>import lang::html::IO;
ok
rascal>characters = {"Sneezy", "Sleepy", "Dopey", "Doc", "Happy", "Bashful", "Grumpy"};
set[str]: {"Happy","Sleepy","Bashful","Grumpy","Doc","Dopey","Sneezy"}
rascal>serve(table(characters * characters));

image


To get this effect we used the following library modules:

  • AST contains the HTML abstract syntax tree definition
  • IO knows how to pretty-print HTML
  • Content provides access to the builtin application server of the Rascal REPL

function table

Synopsis

Translates a binary relation to an HTML table element



HTMLElement table(rel[&T, &U] r)

= table([

tr([

td([text("<a>")]),

td([text("<b>")])

])

| <a, b> <- r

]);