Steve,
The async-fragment tag does allow for arguments to be passed to the data provider. The data-provider argument should always be a function with one of these signatures:
- function(args, callback)
- function(callback)
You should use the first method signature if your data provider expects arguments (as in your scenario).
So for example, in the code that renders the template:
var out = fs.createWriteStream('somefile.html', {encoding: 'utf8'});
require('marko').load(require.resolve('./sometemplate.marko')).render({
webServiceDataProvider: function(args, callback) {
var dataUrl = args.dataUrl;
// send request ot get data
callbac(null, {
hello: 'World'
})
}
}, out);
In the template:
<async-fragment data-provider="data.webServiceDataProvider"
var="users">
<!-- Do something with "users" -->
<for each="user in users">
</for>
</async-fragment>
NOTE: I didn't run this code but it should be close (if it doesn't work please let me know).
Let me clarify that Marko does not care how the data provider fetches the data (it could read a file, send an HTTP request, fetch from cache, etc.).
Please let me know if that answers your question or if you would like more clarification.
Thanks,
Phil