Augmenting Hello World to use a Trimpath Template
First, create the HelloWorld application. Go to the javascript link in the portal and update the Main instance to the read the following:
zimki.library.require('trimpath.js');
function hello() {
return zimki.render.trimpath('hello', {});
}
zimki.publishPath("/", hello);
Next, we need to create the template "hello ". Click on the templates link in the portal and click Create instance. Type "hello " into the Instance name box, and the following into the Template box:
<html>
<head>
<title>my greeting</title>
</head>
<body>
<h1>Hello World, using a template</h1>
</body>
</html>
That's it. Visit your realm and you should see the message Hello World, using a template.
What did we do?
First we imported the 'trimpath.js ' library. Then we amended our function, hello() , to return
the result of rendering the template called 'hello ' instead of returning a static string. Then we simply publish the function to a path, as before.
See also
Parent
CookBook.HelloWorld
|