i have a backend service that I wrote in Golang
, something like this:
func PageA_RequestHandler(ctx *W.Context) {
// init things
if is_ajax {
// handle the API request, render the JSON
return
}
// query the initial rows
values := M.SX{
`rows`: model1.GetRows(10),
`columns`: model1.GetColumns(),
}
// render the html
ctx.Render(`page_a_template`,values)
}
then the template file page_a_template.html
(that loaded and cached at the first time it rendered), is a html file, with content something like this:
<div id="grid"></div>
<script>
var rows = {/* rows */};
var cols = [/* columns */]
new GridBuilder('grid',cols,rows);
</script>
Where's:
{/* rows */}
and [/* columns */]
are my javascript-friendly template syntax, there are some other syntax like: /*! bar */
or #{yay}
new GridBuilder
is my custom javascript component that creates something like datatables.net
or editablegrid.net
The question is, if I use Elm
, what's the correct way to inject the {/* rows */}
into the compiled html?