OpenFL custom JS library
The OpenFL library for Haxe contains a number of template files that are used when building a project. You can find them in the assets/templates directory. Using the <template>
element in project.xml, it's possible to provide additional template files to copy to the output directory, on a per-project basis, and without forking OpenFL.
This sample project contains a directory named custom-templates. It is configured in project.xml like this:
<template path="custom-templates"/>
Inside custom-templates, there's a file at html5/template/custom-library.js. This is a custom JavaScript library that needs to be called from Haxe code.
To include an HTML <script>
tag in the index.html for custom-library.js, configure it in project.xml like this:
<dependency name="./custom-library.js" if="html5"/>
There is also a file named src/CustomLibrary.hx that defines Haxe externs for the custom library. Visit Haxe Manual: Using external JavaScript libraries for more details about custom JavaScript library externs.
To build and launch the project, run the following command:
openfl test html5
Sample created by Josh Tynjala, the author of Feathers UI and core contributor to OpenFL.