Hello from HTML2PATS!

HTML2PATS is a tool for converting HTML with embedded ATS2 code into ATS2 code

HTML2PATS can be used as a templating engine or as a preprocessor (when memory safety & runtime efficiency are highly sought after). HTML2PATS can be thought of as a tool for giving a nicer syntax to a class of functions for constructing HTML (fragments).

Basic usage

Comments will be retained as-is.

The length of the passed-in list is 4 (evaluated using a function call: ${length(xs)})

Finally, it is possible to locally implement template functions.

The ats-call tag is used to call a template function (with specified template arguments listed in tmpargs and dynamic arguments listed in dynargs). Below, int;HTMLprint is translated to: <int><HTMLprint>.

The ats-impl tag is used for implementing a function template locally, only visible to the enclosing ats-call.

      <ats-call fun="list_vt_foreach_env" tmpargs="int;HTMLprint" dynargs="xs, out">
	<ats-impl tmp="list_vt_foreach$fwork"
		  tmpargs="int;HTMLprint" dynargs="x, out">
	  <li>$x</li>
	</ats-impl>
      </ats-call>
    

For instance, the result of evaluating the above code fragment is given below:

Advanced usage

It is possible to overload the symbol htmlprint in ATS to provide HTML printers for user-defined data types. To be covered elsewhere.

The API provided by the library htmlprint is documented elsewhere (nowhere currently, to be precise).

A function htmlprint_unsafe_inject is provided that allows for injecting strings as-is, with no escaping. Use at your own risk.

Author and license

The license is 3-clause BSD.

Author: Artyom Shalkhakov (artyom DOT shalkhakov AT gmail DOT com)