-
-
Save RaycatWhoDat/ee6899f2c41d06af6e11c3cac7c48abc to your computer and use it in GitHub Desktop.
Macro issues.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div className="App"> | |
<header className="App-header"> | |
<img src=$logo className="App-logo" alt="logo" /> | |
<p> | |
Edit <code>src/App.hx</code> and save to reload. | |
</p> | |
</header> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import react.React; | |
import react.ReactDOM; | |
import react.ReactComponent; | |
import react.ReactMacro.jsx; | |
import AppTools; | |
/** | |
* This is the main entrypoint for the application. | |
*/ | |
@:expose | |
class App extends ReactComponent { | |
public function new() { | |
super(); | |
} | |
public static function main() { | |
ReactDOM.render(React.createElement(App), js.Browser.document.getElementById("root")); | |
trace("Application loaded."); | |
} | |
override function render() { | |
var logo = js.Lib.require("./assets/logo.svg"); | |
return AppTools.insertTemplate("App"); | |
} | |
} | |
/* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
import haxe.macro.Expr; | |
#if macro | |
import sys.io.File; | |
#end | |
using haxe.macro.Tools; | |
class AppTools { | |
public macro static function insertTemplate(templateName: String) { | |
var template = ""; | |
try { | |
template = File.getContent('./${templateName}.html'); | |
} catch (error: String) { | |
trace("Error: " + error); | |
} | |
return macro react.ReactMacro.jsx($v{template}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment