1.   art-template Not only can you try it out in the browser , Also available at node use
first , Install in the file directory to be executed art-template, Installation procedure : Enter after the file where the command line is located :npm install art-template

And then you'll find out , There will be one more directory under the file :node_modules

This is what we're looking for , That is, you need to refer to this file in the browser ;
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script src="node_modules\art-template\lib\template-web.js"></script>
    <script type="text/template" id="tpl">
        hello everyone , My name is :{{name}};
        I {{age}} year ;
        I come from {{province}} province ;
        Educational background {{education}};
        My hobbies are :{{each hobbies}} {{$value}} {{/each}}
    </script>
    <script>
        var person = template("tpl",{
            name:"Jack",
            age: 18,
            province : " Jiangsu ",
            education:" Master's degree ",
            hobbies: [
                " sing ",
                " Calligraphy ",
                " Swimming "
            ]
            });
        console.log(person);
    </script>
</body>
</html>

2. stay Node Use in art-template template engine

js file :
var template = require("art-template"); var fs = require("fs");
fs.readFile("H2.html",function (err,data) { // Here is the path to read the file , Where is it js The relative path of the file if (err){
console.log(" File read failure "); } var ret = template.render(data.toString(),{
name:"Jack", age: 18, province : " Jiangsu ", education:" Master's degree ", hobbies: [ " sing ", " Calligraphy ",
" Swimming " ] }); console.log(ret); });
html file :
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8">
<title>Title</title> </head> <body> <p> hello everyone , My name is :{{name}}</p> <p> I {{age}} year </p>
<p> I come from {{province}} province </p> <p> Educational background {{education}}</p> <p> My hobbies are :{{each hobbies}} {
{$value}} {{/each}}</p> </body> </html>

Technology
©2019-2020 Toolsou All rights reserved,
A summary of the computer retest interview questions var a = 0, b = 0; function A(a) {A = function (b)... An interview question about scope 【 Data structure and algorithm 1】 Sparse array 2020—— Net tripod cup part writeupPTA-MOOC《Python Programming Zhejiang University 》 Puzzle A Chapter 2 programming problems python closure uniapp Dynamic routing parameter transfer ( Delivery object ) How to use it Python Batch import Excel Combined use Pandas integration Lambda Expression and functional interface 【Java Details of knowledge points 3】 Serializable and Deserialize