Can we use JSTL in ReactJS? - javascript

Is it possible to use JSTL (JavaServer Pages Standard Tag Library) along with ReactJS and JSP?
ReactJS uses JSX (JSX is a syntactic extension to Javascript). Same way can it use and implement JSTL also. Though ReactJS is front end library and JSP is server side scripting, can it be achieved to a minimal extend?

It is not possible, any extension in javascript is for the browser, so it's running at clien't side. While JSTL is a server side library.
The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags.
You can use it on the backend in the modern browser. You can also use it on the frontend for the client that has no javascript enabled. But it's rarely used today.

Related

hwo html, css, js integration in the browser actually works?

I'm a person who comes from algorithm and data structures background (in c++, c, Python, Java and etc.) and my only experience in frontend is Processing and p5.js. How browsers integrate html, css and js?
Do Javascript scripts generate a new .html file as page at certain framerate? How does it really work inside the browser? Or do most popular libraries like Angular make "syscalls" to the web browser to generate content?
Does using libraries like Angular etc. make generating new html "frame" documents somehow automated for dynamic pages?
I mean apart from all Javascript operations isn't the final displayed content a html file in the end?

how can i use Django with html CSS JS?

I am making a website and through some sources. I find out that Django is for backend and html CSS and JS is for front end.
So I am designing my pages in the later 3 and not started developing the backend.
Is there any way that I can use Django with html CSS and JS? (please suggest an easy method as I am a newbie ,however I am quite familiar with python )
Django would be used to match urls with pages. Specifically you would need to create a view that renders a template (here comes the html) and some static files (css, js). If you wont use a database i would suggest that you use flask which does the thing is described above much more easily.

Client-side solution similar to asp.net master page

I recently started using WebStorm to implement web applications and find the experience much better than using Visual Studio.
I am considering moving the "view" part in mvc to pure html as much as possible without relying on server template engine such as Razor. So that I don't have to open visual studio until server side code is needed.
Google results showed that client side template engines such as Handlebars and Mustache will be able to help generate dynamic html pages. One thing I have not found is that ability to combine "parts" of pages together (like the master page in asp.net) so that we don't need to copy/paste header/footer everywhere.
How do I achieve "master page"-like functionality with client side (i.e. javascript) solutions?
Thanks for your help.
You could try this:
use 'shtml' file to struct your webpage,so that you can reference the include instruction:
<!--#include file="head.html"--><hr><b>Hello,this is body!</b><hr><!--#include file="foot.html"-->
As to 'head.html' and 'foot.html',well,you know what should include in them.Actually,they are 'div' segments~~~

Javascript Templating with Django

I'd really like to use a Javascript templating system together with Django. The syntax and style of Mustache.js (and it's derivatives) really sits well with me. The problem is the delimiter tag used by Mustache doesn't play nicely with the syntax of Django's templating system.
Is there any good way to use them together?
I have tried using this verbatim snippet to render the JS templates properly. The problem with that solution is I still sometimes need Django variables or URLs inside the JS.
I have also tried changing the delimiter for Mustache using
{{=[[ ]]=}}
However, that doesn't allow for using section tags, like {{#}}. The author has said he intends on removing that capability in future releases altogether.
Are there any template libraries for Javascript that follow closely to Mustache.js, but use different delimiters? Or is there another solution for changing the delimiters Mustache.js uses?
I've used jquery's templating with django. Ultimately I decided the best way is:
put all the javascript into static javascript files and serve them up without any serverside processing
in the django templates deliver all the html hooks (id's or classes) but no js.
in the js use 'document.ready' plus jquery selectors to insert tags into the page and attach events
if the js needs data then make an ajax call.
I softened on the last one and might embed data as a block of json into the django template, and perhaps also have a short js at the bottom of a template which do no more than set variables/parameters to instruct the js how to render the page - little clues from the server side telling it what to do.
Thus:
contention between the escape characters becomes a non-issue
you don't have to keep asking yourself "is this code running on the server or on the client" because you're not trying to write both at once into the one file
your javascript code is necessarily better structured and re-usable
It looks like it would be extremely easy to change Mustache's delimiters, although configurable delimiters should be supported in my opinion.
If this is not acceptable to you, there are many other templating libraries out there such as jquery-tmpl and underscore.template.
EJS is a pretty nice templating system. It uses <% %> tags.
Edit: More templating libs

Multilanguage support in my Javascript code

I'm using Django and I need to support multilanguage in my Javascript code. But my Javascript files are into site_media so they are not rendering by the template engine. I would like to learn what is the most common solution for this situation, how do you handle it generally?
Thanks
You may want to look into the l10n.js library I've written. The benefits are that you can separate language data files and code in a way that only optionally requires l10n.js.

Categories

Resources