发布于 2015-09-26 03:26:51 | 142 次阅读 | 评论: 0 | 来源: 网络整理

全局变量是存储在 harp.json 文件中的 JSON 数据,对所有的页面、模板、局部视图以及布局文件可用。

为什么呢?

Harp 不仅仅只是静态文件,页面也可以通过动态内容创建。像全局属性中添加内容是天生可取的。

harp.json

{
  "globals": {
    "title": "Acme Site",
    "name"  : "John Doe",
    "uri": "http://example.com"
  }
}

Jade 示例

index.jade

html
  head
    title #{ title }
  body
    h1 Hello #{ name }!

EJS 示例

index.ejs

<html>
  <head>
    <title><%= title %></title>
  </head>
  <body>
    <h1>Hello <%= name %>!</h1>
  </body>
</html>
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务