This is a short Sioux tutorial. It shows how to write and build simple Nemerle web application.
First of all open your favorite text editor and start coding:
using Sioux;
using Nemerle.Xml;
using System.Xml;
public class MyFirstApp : Application
{
override protected DoGet() : void
{
def doc = XmlDocument();
doc.Load("my_first_app.xml");
this.FormTemplate = Some (XmlTemplate(doc));
}
}
|
Now, we'll explain our code:
using Sioux;
|
using Nemerle.Xml;
using System.Xml;
|
public class MyFirstApp : Application
{
...
}
|
override protected DoGet() : void
{
...
}
|
def doc = XmlDocument();
doc.Load("/my_first_app.xml");
this.FormTemplate = Some (XmlTemplate(doc));
|
All we have to do now is to write my_first_app.xml. Here's the code:
<html>
<head>
<title>My first Sioux application</title>
</head>
<body>
<h1>
This is my first Sioux application
</h1>
</body>
</html>
|
Let's assume that we have two XML files: file1.xml and file2.xml and we want to use
them both in our application.
<!-- FILE1.XML -->
<html>
<head>
<title>First file</title>
</head>
<body>
<h1>
This is file1.xml
</h1>
</body>
</html>
|
<!-- FILE2.XML -->
<html>
<head>
<title>Second file</title>
</head>
<body>
<h1>
This is file2.xml
</h1>
</body>
</html>
|
using Sioux;
using Nemerle.Xml;
using System.Xml;
public class SecondApp : Application
{
override protected DoGet() : void
{
def doc = XmlDocument();
match(PageName)
{
| "/file2.xml" => doc.Load("file2.xml");
| _ => doc.Load("file1.xml");
}
this.FormTemplate = Some (XmlTemplate(doc));
}
}
|
There is one part of code different than in first example:
match(PageName)
{
| "/file2.xml" => doc.Load("file2.xml");
| _ => doc.Load("file1.xml");
}
|