<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # [art-template文檔](https://aui.github.io/art-template/zh-cn/docs/index.html) ## 1.安裝配置 ~~~ npm install --save art-template npm install --save koa-art-template ~~~ ## 2.Example ~~~ const Koa = require('koa'); const render = require('koa-art-template'); const {resolve} = require('path'); const app = new Koa(); render(app, { ?root:resolve(__dirname, 'views'), ?extname: '.html', //后綴也可以寫成.art ?debug: process.env.NODE_ENV !== 'production' }); ? app.use(async function (ctx) { ?await ctx.render('user'); }); ? app.listen(8080); ~~~ ## 3.實例 ~~~ const Koa = require('koa'); const router = require('koa-router')(); const render = require('koa-art-template'); const {resolve} = require('path'); const app = new Koa(); /* 配置模板引擎 */ render(app, { ? ?root: resolve(__dirname, 'views'), ? ?extname: '.html', ? ?debug: process.env.NODE_ENV !== 'production' }); router.get('/', async ctx => { ? ?await ctx.render('index',{name:"chengchao"}) }) app.use(router.routes()).use(router.allowedMethods()) app.listen(8080) ~~~ ## 4.基本語法 ### 4.1 if ~~~ {{if isShow}} ? ? <p>加載更多</p> {{/if} ~~~ - if-else ~~~ {{if isShow}} <p>加載更多</p> {{else}} <p>不要加載</p> {{/if}} ~~~ ### 4.2 遍歷 each ~~~ {{each arr}} ? <p>{{$index}}-{{$value}}</p> {{/each}} ~~~ ### 4.3 模板繼承 #### 標準語法 ~~~ {{extend './layout.art'}} {{block 'head'}} ... {{/block}} ~~~ 模板繼承允許你構建一個包含共同元素的模板“骨架”。范例 ~~~ //骨架模板 <!--layout.html--> <!doctype html> <html> <head> ? ?<meta charset="utf-8"> ? ?<title>{{block 'title'}}My Site{{/block}}</title> ? ? {{block 'head'}} ? {{/block}} </head> <body> ? {{block 'content'}}{{/block}} </body> </html> ~~~ ~~~ //index.js <!--index.art--> {{extend './layout.html'}} ? {{block 'title'}}{{title}}{{/block}} ? {{block 'head'}} ? ?<link rel="stylesheet" href="custom.css"> {{/block}} ? {{block 'content'}} <p>This is just an awesome page.</p> {{/block}} ~~~ ### 4.4 子模板 ~~~ {{include './header.html'}} ~~~ ### 4.5原文輸出 ~~~ {{@value}} ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看