How to integrate curl.js with server-side jinja2 templating - javascript

I have a Python-based Flask web application that uses Jinja2 to perform templating on the server-side.
I would like to improve my Javascript and CSS loading by using curl.js to load JS and CSS asynchronously.
Is there a specific, well-defined method for doing this?

Related

How Do I Use/Import my Java Locale class and Resource Bundle properties to be used in my HTML files (not JSP)?

For my current project, I have a Spring Boot REST service backend using JSON and a set of asynchronous HTML files for the frontend accessing the REST service using AJAX. I want to use my Java localization class and my resource bundle properties file for the languages I need which I had created and it worked fine for my previous projects which only used JSP pages.
However, for my new project, I am using purely asynchronous HTML files with AJAX (jQuery and vanilla Javascript) and no JSP front-end to connect to my Java backend. So how do I import and use my Java i18N features in my purely HTML files with AJAX without any JSP?
You cannot have Java code in HTML file. The way it works with JSP is because JSP simply gets compiled to Java Servlets while compilation stage and then they run. The best bet to make it work with HTML along with Ajax is, create some kind of meta controller, which provides you the required data related to localization and internationalization in response, and then use it with JavaScript.

Using Blazor (i.e. WebAssembly) + javascript

Im really excited at what WebAssembly can bring to us web UI developers.
Now correct me if im wrong, but a web assembly / blazor project can easily and happily coexist with javascript. The script might handle all the http web requests and various clientside manipulations.
Your thoughts?
Yes, you could do that, as of version 0.4 it is easy to interop between c# and javascript and vise versa.
But you don't have to, the beauty of blazor is that you can just use the HttpClient class from .net framework System.Net.Http namespace for calls to your backend.
And make razor cshtml components for DOM manipulation.
More on http calls from blazor
More on js interop

Compiling dust.js template to html server side?

Is it possible to compile dust.js template to plain html?
I tried dusty and dustc serverside compilers but they generates a javascript file which will write the content of the template on the page.
Dust only compiles to JavaScript, but you can use a compiled template to render plain HTML. This works the same on the server and on the client. On the server you need to use Node.js or Rhino (or some other engine that interprets JavaScript).
It is possible to render a dust template directly to HTML, but it is not recommended. Anyway, this can be done with pyv8 a Python bindings for V8 JS engine.
In this article Andrew Wilkinson show how he made it for mustache.js.

Is there a javascript templating library that uses the same syntax as the one in PlayFramework 1.x?

I am looking for a javascript templating library that exactly matches the syntax of the Play 1.x templating language, so I can share templates in a client-server environment.
Not to my knowledge.
But there is a Mustache module for Play 1.x, which allows you to "define logic-less template snippets that can be used server-side in your Play views as well as client-side in your JavaScript" according to the modules homepage.

HTML templating solution for both ASP.NET MVC and browser?

I'm trying to find an HTML templating solution that will work both on my ASP.NET MVC application (.NET 4, IIS 7.5) and in the browser. The reason is to the the same code to render HTML both on the server (performance, outputting to mobile, etc) or on the browser (refreshing data via AJAX). This is not a new problem, but I am wondering if current technology trends have changed the answer.
A couple of ideas I am considering:
Use mustache templates with are available in both
JavaScript and .NET.
Use a port of the Razor View Engine to
JavaScript like considered in Javascript + Razor == Jazor?.
Take a position like Micro Templates Are Dead... forget about it and
just use JavaScript (IronJS?) and the DOM (jsdom)
ASP.NET MVC View Engine Comparison looked relavent, but there is no mention of mustache.
Update: The client-side templating throwdown: mustache, handlebars, dust.js, and more from LinkedIn Engineering rates mustache in it's top four, with it being the only one with native .NET rendering (vs requiring server-side JavaScript to render on the server).
I would highly recommend mustache for your application. You have already mentioned abt the fact that it has a server side rendering engine and also a strong community backing. Apart from this the major reason why I would recommend mustache is for Performance of the templating engine. I have played around with the same and none of the other JS templating solution could match the performance of mustache.
What I would like more is documentation around the library but you should be able to work around this.
I have done that using Spark view engine, it is quite good with the template where you can use it from .net and js.

Categories