First,the thinkjs2.x default template engine is Ejs, instead of Art-template,art-template is a simple, ultra-fast template engine (https://aui.github.io/art-template/ zh-cn/docs/).
Second, switch to the project more directory installation Art-template dependencies:
installation command: npm Install [email protected]^3.0.3--save
iii. Create a new Art-template.js file under the Src\common\adapter\template directory of the Project
Command: THINKJS adapter Template/art-template
To modify the Art-template.js file code:
' Use strict ',/** * Base Adapter */import template from "art-template"; Export default class extends Think.adapter.base {
/** * Init * @return {[]} [] */ init (... args) { super.init (.... args) } Run (templatefile, TVar, config) { template.config (' Extname ', ""); if (this.env! = "Production") { template.config ("cache", false); } Return template (TemplateFile, TVar);} }
Iv. Modify the View.js file in the Src\common\config directory
' Use strict ';/** * Template config */import template from "art-template"; export default { type: ' Art-template ',
content_type: ' text/html ', file_ext: '. html ', File_depr: ' _ ', root_path:think. Root_path + '/view ', adapter: { }};
To this, the Art-template template engine configuration is complete.
Onlystrive Source: http://www.cnblogs.com/zyuc/ This article is copyrighted by the author, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link. |
thinkjs2.x Configuring the Art-template template engine