marko-js / cli

command-line tools for Marko
MIT License
94 stars 36 forks source link

Pre-loading data before rendering #191

Closed treeder closed 3 years ago

treeder commented 3 years ago

I understand you can do this if you use marko with another server, but it would be nice to be able to do this with marko serve. Basically just to have some data passed into the input so the full page has access to the data.

Is this possible right now?

DylanPiercey commented 3 years ago

What works best is to load the data at the page level. Eg you can:

index.marko

<my-layout>
  <await(fetchDataSomeHow())>
    <@then|data|>
      <my-app data=data/>
    </@then>
  </await>
</my-layout>