Protected Filters

One of the goals of Templates is that its defaults should be safe enough to be able to execute arbitrary templates by untrusted 3rd parties.
Given this constraint, only default filters are pre-registered which contain a comprehensive set of filters we deem safe for use by anyone.
Other filters available in Templates which are useful to have in a server-generated website environment but we don't want 3rd Parties to
access are filters in
TemplateProtectedFilters.cs.

TemplateProtectedFilters are not pre-registered when creating a new TemplateContext but they are pre-registered when
registering the TemplatePagesFeature ServiceStack Plugin as that's designed to use Templates as a View Engine where access
to its context is limited to the server's Web Application.

includeFile

fileContents

Use includeFile to embed content directly within templates:

page.html

my-file.txt

Cascading resolution

If an exact match isn't found it will look for the closest file with that name it can find, starting from the directory
where the containing page that uses the filter is located and traversing up until it reaches the root folder.

includeFileWithCache

fileContentsWithCache

If your VirtualFiles is configured to use a combination
of various sources that includes a remote file service like
S3VirtualFiles, you'll
likely want to cache the contents in memory to ensure fast subsequent access the next time the file is requested,
which you can cache without expiration using includeFileWithCache without arguments:

{{ 'my-file.txt' | includeFileWithCache }}

In which case it will use the 1 minute default overridable in Args[DefaultFileCacheExpiry]
or if you want the content to be refreshed after 1hr you can use:

{{ 'my-file.txt' | includeFileWithCache({ expiresInSecs: 3600 }) }}

includeUrl

urlContents

You can also embed the contents of remote URLs in your page using includeUrl:

page.html

includeUrl is actually a very flexible HTTP Client which can leverage the
URL Handling filters to easily construct urls and the additional
filter arguments to customize the HTTP Request that's sent, here are some examples:

Accept JSON responses:

{{ url | includeUrl({ accept: 'application/json' }) }}

{{ url | includeUrl({ dataType: 'json' }) }}

Send data as form-urlencoded in a HTTP PUT Request with a Templates User-Agent:

includeUrlWithCache

urlContentsWithCache

In the same way includeFileWithCache can cache file contents, includeUrlWithCache can cache URL content,
either without an expiration:

{{ url | includeUrlWithCache }}

In which case it will use the 1 minute default overridable in Args[DefaultUrlCacheExpiry]
or if you want to ensure that no more than 1 url request is made per hour for this url you can specify a custom expiry with: