O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—Creating our template

Now, let's create a template that will simply take an object with the property posts to hold our list of posts.

Add this code to your template.html file:

<html>
<head>
<title>List of Posts</title>
</head>
<body>
<!-- Simply display a greeting -->
<h1>Hi and welcome on my blog!</h1>
<!-- Iterate over all Posts -->
::foreach posts::
<!-- Display's the blog post's title -->
<h2>::title::</h2>
<!-- Display's the blog post's body -->
<div>::body::</div>
::end::
</body>
</html>

You will also want to include this file as a resource named template.

To do so, just add the following to your compilation command:

-resource template.html@template

That's all it takes.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required