Next: , Previous: , Up: Programming Interface   [Contents][Index]

5.6 Artifacts

(use-modules (haunt artifact))

Artifacts are objects that represent the output of a build. A collection of artifacts forms a complete website. Artifacts are quite simple: They contain a file name string that specifies where the artifact belongs in the build output directory, and a writer procedure that populates that file with data.

For example, making an artifact that writes “Hello, world!” to /hello.txt would look like this:

(make-artifact "/hello.txt"
               (lambda (output)
                 (call-with-output-file output
                   (lambda (port)
                     (display "Hello, world!\n" port)))))

Previous versions of Haunt made a distinction between pages, whose content is defined algorithmically, and assets, whose content is copied verbatim from an input file such as an image. The artifact data type is a unifying primitive that replaces both pages and assets.

Artifacts that require serializing some input, such as SXML, should use serialize-artifact. Artifacts that make a verbatim copy of an input file should use verbatim-artifact. Unless you are implementing a custom builder, it’s unlikely that these procedures will be need to used directly.

Procedure: serialized-artifact destination obj serialize

Return a new artifact whose writer serializes obj using the procedure serialize to the destination in the build output directory.

Procedure: verbatim-artifact source destination

Return a new artifact that copies the file source verbatim to destination within the build output directory.