HASH files Last updated: 02. Aug 2023

.HASH files are text files such as HTML pages that execute on server side. They use JavaScript (#JS syntax - aka HashJS) code to process and bind data to your output files. The files must be static and will only be generated once. They will always be cached until the underlying data for the file has changed.

When to use

Use hash files when you are generating static content for your websites / webapps. Such as HTML, CSS, JSON or TXT files.

How to use

Create files in your published sites or in your site template with the file extension .hash

Test.hash

<html>
    <head><title>Test</title></head>
    <body>
        This is a test. By using the hash followed by curly I can write JS for server side generation:
        #{
            // This will run my javascript on server:
            var myValue = 10 + 10;
            write(myValue); // Write 20 to page
        }#
        
        If I simply want to bind a value I can use the shorthand withouth curly:
        #myValue# 
        
        Single statements only if no curly, don't end with ;
        This will bind the value of x to the page.
    </body>
</html>

The example above may not seem very useful. But it becomes very useful when you bind data to your pages from your Docly™ document database. Let's say you make a Docly™ Schema for a "Rental property". And make a HTML display template for it in a hash file:

<html>
    <head><title>Test</title></head>
    <body>
        Property name: #Name#
        Price: #format(Price, "N")#
        Image: <img src="#docly.linkImage(Image, 250, 250, 2)#" alt="Image" />
        Etc...
    </body>
</html>

The "Docly" function library connects your Javascript code to Docly™ data

Read about all the javascript functions and see examples here:
https://developers.docly.net/JavaScript/

Directives (SSI)

SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served.

Directive Example Description
Include directive <!--#include file="... Includes another file in this file.
Master file directive <!--#master file="... Uses an other file as a master page. Read more:
https://developers.docly.net/Blog/2014/Setting-up-and-using-a-Master-Page