Time for action – Reading the template from resources

To read our template from resource and store it, we will simply add these lines of code:

var templateCode : String;
templateCode = haxe.Resource.getString("template");

So, we now have the following:

import Post; class Main { public static function main() { //Parameters to connect to the MySQL database var cnx = neko.db.Mysql.connect({ host : "localhost", port : 3306, database : "myBlog", user : "root", pass : "", }); //Initialize the SPOD system neko.db.Manager.cnx = cnx; neko.db.Manager.initialize(); var posts = Post.manager.all(); var templateCode : String; templateCode = haxe.Resource.getString("template"); //We've done our processing, let's clean things and disconnect neko.db.Manager.cleanup(); ...

Get haXe 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.