Chapter 4. Compilation with Kermeta

Ket templates should be compiled to generate a Kermeta file. Right click on your KET file and select Kermeta -> Translate Kermeta Template. You get a new .kmt file with the same name of your KET template. The .kmt file contains a Kermeta class that conforms to the parameters you provide. This Kermeta class provides also a generate(...) operation you would execute to pretty-print the text you expect.

<%@ket
package="hello_world"
require=""
using=""
class="Hello_World"
parameters=""
%%>
<%-- Pretty printer code --%>
Hello World !!
package hello_world;
require kermeta
using kermeta::standard
using kermeta::utils
class Hello_World{
operation generate():String is do
var _res: StringBuffer init
StringBuffer.new

// Pretty printer code
_res.append("Hello World !!")
result := _res.toString
end
}

4.1. Nesting templates

If you need to nest templates because you produce modular templates that can be included in each other, one way is to enclose the generate(...) operation you get from the generated Kermeta file into a Kermeta scriptlet.