N
N
ne_pes2018-03-19 21:22:58
css
ne_pes, 2018-03-19 21:22:58

Why is nunjucks needed, how can it help in front-end layout?

Why is nunjucks needed, how can it help in front-end layout? I can not understand. Can you recommend any course/manual?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dima Polos, 2018-03-19
@ne_pes

Let me give you an example of my use cases. If there is a project with a size of, for example, 10 or more pages (one of my last 50+ pages), and they have a header, footer and menus that are repeated. Imagine that you do all this with copy-paste, and then you need to add another item or the layout of the header will change ... Changing manually is hell. In nunchucks, you can have a header and a footer, and connect the menu as modules, if something has changed - edit only one file, it changes everywhere at once.
Option two, you need to check and show the layout for reliability, overflowing the container, for example, there is a table, you can manually copy paste 30 lines, but then the document will be large and scrolling will be inconvenient, plus your eyes will get tired, in addition, you may need some -to set your special classes for every 10th line, and then add a couple more lines, and the order of the table rows has changed, and manually change all classes. In nunchucks, it is possible to create an array, as in programming, and run a loop with conditions and other goodies, and now you can add a couple of lines without any problems, simply by adding the necessary values ​​​​to the array.
You can also insert svg into html, while not visually clogging the code, as a result, you can manage svg as part of the document, and at the same time cleanliness and order in src files.
https://mozilla.github.io/nunjucks/ Here are the docs.

I
Ivan Bogachev, 2018-03-19
@sfi0zy

How can it help in front-end layout? I can not understand.

In general , nunjucks is similar in syntax to handlebars , and there is also pug (formerly jade) - a similar tool (part-time preprocessor) that you should definitely look into.
All these tools (there are many different ones in general), which can be combined with the word "templaters", are needed by the front-end in different situations:
You can think of other uses.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question