klattimer/SystemDashboard

Server side template language

Closed this issue · 6 comments

We want to use mako to construct templates on the server side, this will let us include templates for the client side and the container HTML.

@LameLemon

mako is pretty decent

Do you have any resources with examples similar to what you plan on achieving with mako? A little confused on how it works.

@klattimer

So, if I'm understanding this correctly we have the HTML file and instead of the specifying the CSS file we have a variable, say ${css_file}. Then in Python we load this HTML has a template and enter the CSS filename through the variable css-file and render?

I've read through the documentation, I'm just having trouble understanding how the template file is structured. I haven't been able to find many examples or other information around the web either.

p.s. when we render do out write over the static HTML or in what other way could we serve it? In other words where and how I render it?

So I guess I need to describe this in some detail, that's OK.

First, we need an endpoint which is going to serve the appropriate template rendered files, in the API folder we need to create something which provides both / and /signin endpoints.

This is fairly straight forward, take a look at the plugins in /API to see how that might work, but I think I'll just throw out a boiler plate for that in my next merge (coming soon, lots of features)

Next we have a template file which we'll call container, the container has a couple of blocks in it which we can insert into, one of them is the header, the header will allow us to include scripts and stylesheets specified by the endpoints.

When render occurs, it'll accumulate all the scripts and stylesheets that are specified by the plugins, and add header tags for those, then, a list of templates (I think handlebars is best) are inserted into the stylesheet, for rendering the individual components.

What we'll do is start with the CSS/JS being bundled with the plugins and we'll move on from there to other stuff.

I'll throw out some boiler plate to get things started, and do my merge :D

I've pretty much done this. I'm going to merge in shortly.