using web::WebOutStream
** A `Directive` to include the contents of the given file as raw text. Handy for including header
** and footer html.
**
** INLCUDE: snippets/header.html
**
** Fan resources may also be included:
**
** INLCUDE: fan://myPod/snippets/header.html
**
** @since 1.0.4
class IncludeDirective : Directive {
override Void invoke(WebOutStream out, Uri? base, Str text) {
uri := `$text`
if (uri.isRel && base != null) {
if (!base.isDir)
base = base.parent ?: base.plusSlash
uri = base + `$text`
}
IncludeDirective#.pod.log.debug("Including '$uri' in '$base'")
includeFile := uri.get as File
includeHtml := includeFile.readAllStr
out.printLine(includeHtml)
}
}