這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)怎么在node環(huán)境中使用parse Smarty模板,文章內(nèi)容豐富且以專(zhuān)業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
// index.js: const express = require('express'); const smarty4Js = require('smarty4Js'); const path = require('path'); const app = express(); const smartyHelper = new smarty4Js(); const basePath = path.resolve('./'); smartyHelper.setBasedir(basePath); const compiler = smartyHelper.compile('./index.tpl'); const html = compiler.render({ title: 'node-parse-smarty', body: 'Smarty' }); console.log(html); app.get('/', (req, res) => { res.header('text/html'); res.end(html); }); app.listen(3000, () => { console.log('app is run at 3000 port'); });
// index.tpl:{%$title%} {%$body%}
結(jié)果如下:
上述就是小編為大家分享的怎么在node環(huán)境中使用parse Smarty模板了,如果剛好有類(lèi)似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。