-
-
Save kLabz/df551e47f898ab9f2fa55d346af89c84 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'); | |
trace(template); | |
} 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