From f77109be5240deda6bcc7807780b397846107340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sun, 19 Apr 2020 11:27:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=93=E5=AD=98=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E4=B8=BA=E6=96=87=E4=BB=B6=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 11 +++++++---- package.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index a654887..e3fc850 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ /** - * nodeJS 模板引擎(依赖doJS框架) + * nodeJS 模板引擎 * @authors yutent (yutent@doui.cc) * @date 2015-12-28 13:57:12 * @@ -10,6 +10,7 @@ require('es.shim') const Tool = require('./lib/tool') const path = require('path') +const fs = require('iofs') function hash(str) { return Buffer.from(str).toString('hex') @@ -76,20 +77,22 @@ class Smarty { key = hash(tpl) if (this.__CACHE__[key]) { - return Promise.resolve(this.__CACHE__[key]) + return Promise.resolve(fs.cat(path.resolve('./cache/', key))) } cache = this.tool.__readFile__(tpl, noParse) if (noParse) { - this.__CACHE__[key] = cache + this.__CACHE__[key] = true + fs.echo(cache, path.resolve('./cache/', key)) return Promise.resolve(cache) } try { cache = this.tool.parse(cache, this.__DATA__) if (this.opt.cache) { - this.__CACHE__[key] = cache + this.__CACHE__[key] = true + fs.echo(cache, path.resolve('./cache/', key)) } return Promise.resolve(cache) } catch (err) { diff --git a/package.json b/package.json index d27fd95..20f4cdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smartyx", - "version": "1.3.1", + "version": "1.4.0", "description": "nodeJS模板引擎,理念源自于PHP的smarty模板引擎", "keywords": ["fivejs", "smarty", "template", "ejs", "jade"], "author": "宇天 ",