The controller is written in Fortran itself:
Here is an example where you write HTML using multiline strings:
case ('/html') ! HTML write(unitNo,AFORMAT) '<div class="container">' // & '<h1>Hello World</h1>' // & '</div>'
Here is an example where you load a Jade template:
case ('/') ! most pages look like this templatefile = 'template/index.jade' call jadefile(templatefile, unitNo)
You have access to URL variables:
case ('/search') call cgi_get(dict, 'q', query) call calculate(query)
Jade files can also have template strings with each variable in a #{template}. Pass variables using the pagevars 2D array.
case ('/profile') pagevars(1,1) = 'name' pagevars(1,2) = 'Nick' templatefile = 'template/profile.jade' call jadetemplate(templatefile, unitNo, pagevars)
In searches Fortran.io controller gets input from the model and URL variables, and displays it in the view.
case ('/search') pagevars(1,1) = 'name' pagevars(2,1) = 'latinName' call cgi_get( dict, 'q', query) call getOneMarsupial(query, pagevars(1,2), pagevars(2,2)) if (len(trim(name)) == 0) then write(unitNo,AFORMAT) 'No results in this database :-(
' else ! template with string templatefile = 'template/result.jade' call jadetemplate(templatefile, unitNo, pagevars) endif