In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use the Dust js template engine", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use the Dust js template engine"!
Introduction to Dust.js Grammar
Express4.0 default template engine is jade,jade just started to feel like python, there is a strict syntax format to facilitate programmers to develop good coding habits, but in the actual use will find this mandatory, in the template side to write a logical language, especially in the nesting judgment when there will be some insurmountable problems, while its performance problems have been criticized by others. Of course, you can also ejs or other templates, which is not the point I want to elaborate.
The realization of Dust.js
If it is an off-the-shelf express project or after using express-genarate to generate the basic structure, add three dependencies to the dependencies of the package.json file.
"dustjs-helpers": "~ 1.3.0"
"dustjs-linkedin": "~ 2.4.2"
"adaro": "^ 0.1.5"
Among them, dustjs-linkedin is the dustjs template itself, and dustjs-helpers is the extension method of some templates, which is explained in the official dustjs documentation, which is very useful. You can add your own helper method. Adaro is a dustjs rendering library provided by paypal, which can be easily used to switch among multiple template engines. Krakenjs, the express-based web framework of paypal, uses adaro as a template management tool.
Then add the usage of the template at the entry code of app
Vardustjs=require ('adaro')
Varapp=express ()
/ / Registration
App.engine ("dust", dustjs.dust ({cache:false}))
/ / viewenginesetup
App.set ('views',path.join (_ _ dirname,'views'))
App.set ('viewengine','dust')
Thank you for reading, the above is the content of "how to use the Dust js template engine", after the study of this article, I believe you have a deeper understanding of how to use the Dust js template engine, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.