Answer the question
In order to leave comments, you need to log in
What is the best way to deal with the template engine in lodash (performance question)?
I am using lodash templating engine in a project. Lodash is simple and not logic-less like mustache. It may not be the best idea to transfer logic to templates, but at this stage, under the current conditions, there is no way to take and rewrite.
Now it works like this: there is a large json containing data. The data has its own key, which determines how it should be rendered. Depending on this key, certain tags with one or another hierarchy are written in the template.
How much slower will it be if each specific subpattern is in a separate file?
That is, the first option is this:
In js, we take json, give it to the template. In the template check
<% if (key='table') { %>
<table>...</table>
<% } if (key ='supertable') { %>
<image><table class="superpuper">... </table><div class="bottom">
<% } if (key ='imageBlock') { %>
<div class="image"><img></div>
<% } %>
key
our own template for a certain one, placing it in the place generated before.
Answer the question
In order to leave comments, you need to log in
How much slower will it be if each specific subpattern is in a separate file?If you have this template rendered less than a million times per second, the difference can be neglected. Well, if you don’t take a word, no one bothers to take and profile.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question