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—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(); ...

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