An archive of community.esquilo.io as of Saturday January 26, 2019.

HTML Templating

ryang14

Would it be possible to implement simple HTML templating using the RPC? For example: putting {function.returnedVariable} in an HTML file would insert the returned variable into the HTML when the page is loaded.

patrick

Yes. You should be able to use any client-side framework that supports this as long as you can update the model with ERPC results in Javascript.

We have a couple of demos in Angular using such a data binding:
https://github.com/esquiloio/lib/tree/master/demos/weather/angular
https://github.com/esquiloio/lib/tree/master/demos/rgb_led/angular

Do you have a framework in mind?

ryang14

I am currently using javascript to insert the variables into my page after it loads and it works fine, but a template language would be much easier and simpler for static pages. Most server frameworks like node.js, flask, jboss, ect. use HTML template languages to insert variables and are easier to use than the ERPC javascript stuff.

patrick

The ones you mention (node, flask, etc) are all server-side template engines. Because Esquilo runs a small embedded HTTP server, it doesn't support this type.

It would need to be a client-side, such as AngularJS. Unfortunately this doesn't avoid the AJAX call to the server, but it does avoid explicitly updating the DOM with the results. Here's a short example:
http://fdietz.github.io/recipes-with-angular-js/consuming-external-services/requesting-json-data-with-ajax.html