ruby uses erb as the default for template processing.
When nodejs wants to do the same template processing, what libraries are common to do this?(Is there such a thing?)
node.js
Node.js has something called EJS.
http://www.embeddedjs.com/
You can install it with the npm
command.
https://www.npmjs.com/package/ejs
In terms of template (layout) extensions, Nunjucks is easy.
(I think EJS found it troublesome to expand the template.)
You can extend the template as follows:
<body>
<header class="main">header</header>
<section class="content">
<nav class="side_nave">navi</nav>
<main>
{% US>block main%}
dummy
{% endblock%}
</main>
</section>
</body>
{%extends"layout.html"%}
{% US>block main%}
This is the main contents
{% endblock%}
<body>
<header class="main">header</header>
<section class="content">
<nav class="side_nave">navi</nav>
<main>
This is the main contents
</main>
</section>
</body>
In nodejs
, pug, handlebars are relatively famous, but there are many other factors, so you can choose according to your preference.The syntax close to erb seems to be EJS.
You can also use the recently rising popularity framework Vue.js as a template to create server-side applications with Nxt.js or static sites with VuePress.If you like new things, it will be interesting to use them.
571 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
609 GDB gets version error when attempting to debug with the Presense SDK (IDE)
910 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
616 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.