Chapter 3 Basic Features

Table of Contents
3.1 Running Cows
3.2 Guidelines
3.3 The First Page
3.4 A Minimal Web Site
3.5 Last Modify Date
3.6 Towards an Improved Header
3.7 Improved Header

In this section I'll use a very bad HTML: in particular, I'll avoid using Cascading Style Sheets in order to reduce the number of files and keep this tutorial as simple as possible. You should refer to other documentation for a guide to writing good HTML.

I'll also often create fragments of HTML files like this:

<h1>Title</h1>
<p>Content</p>

This is not a complete HTML file, since it misses at least the Document Type Definition, head and body sections. Of course, whenever you decide to use G-Cows or not, you'll have to use standard HTML syntax for your sites.

3.1 Running Cows

Cows is the interpreter for the G-Cows scripting language. It parses a text file and looks for <cows> tags. Everything outside these tags is sent verbatim to output while everything inside is considered a script and executed; script's output is sent to output too.

File hello.cws

<h1>Running Cows</h1>

<p>
<cows echo ("Hello World from Cows"); />
</p>

This is a very simple input file. We want Cows to parse it and execute the script; the usual way to invoke Cows is:

cows input-file output-file

$ cows hello.cws hello.html
$ cat hello.html

<h1>Running Cows</h1>

<p>
Hello World from Cows
</p>

As you can see, Cows created a file consisting in a verbatim copy of hello.cws with the script replaced by its output. Of course this is a trivial example: you'll never use Cows for such a simple task.

Another simple example:

File hello2.cws

<cows  message="Hello World from G-Cows";  />

<h1>Running Cows</h1>

<p>
<cows echo (message); />
</p>

There are two scripts now, let's run Cows and see what happens:

$ cows hello2.cws hello2.html
$ cat hello2.html

<h1>Running Cows</h1>

<p>
Hello World from G-Cows
</p>

As you can see, you can have more than one script in the same file and Cows will parse them as if they were a whole. As a consequence of this, the variable message defined within the first script is accessible from the second one.

This manual can be downloaded from http://www.g-cows.org/.