thinkjs2.x Configuring the Art-template template engine

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.