I currently have a website using PHP (Laravel) on the server and Javascript in the client. Now I'd like to replace the Javascript with Dart.
On the current webpage, I inject some data into the Javascript like this:
<script>
var mydata = <?php echo $mydata; ?>;
/* now do something with mydata */
</script>
My question is: how do I rewrite this to Dart?
My first take would be:
<script type="application/dart">
main() {
var mydata = <?php echo $mydata; ?>
/* now do something with mydata */
}
</script>
But this approach makes it impossible to generate Javascript code with dart2js since there is dynamically generated code included in the Dart code.
I can of course use an Ajax request, but I choose to place the generated data in the Javascript code because that makes one less HTTP request, making the webpage load faster.
So how would I go about injecting PHP generated data into Dart, without using a HTTP request while still being able to use dart2js?