fs.readFile('./src/template/pages-for-tag.hbs', 'utf8', function (err,data) {
          if (err) {
            return console.log(err);
          }
          var result = data.replace(/%TAG_NAME%/g, item);

          fs.writeFile('./src/pages/tag/' + item + '.hbs', result, 'utf8', function (err) {
             if (err) return console.log(err);
          });
        });
示例#2
0
文件: index.js 项目: fzembow/todoview
  app.post('/config', function(req, res){
    var c = validateConfig(req.body);
    if (c){
      config = c;

      fs.writeFile(CONFIG_FILENAME, JSON.stringify(c), {encoding: "utf8"}, function(err){
        if (err) console.log(err);
        res.sendStatus(200);
      });
      
    } else {
      res.sendStatus(400);
    }
  });