小编pha*_*see的帖子

订购Meteor加载的css和js文件

有没有办法为Meteor加载的自动加载的css或js文件指定顺序.

搜索了文档但找不到任何内容.

我问,因为我正在玩舞台,我正在尝试使用Twitter Bootstrap和Meteor.在Bootstrap附带的示例中,始终在bootstrap-responsive.css之前加载基本bootstrap.css.

有任何想法吗?

meteor

41
推荐指数
2
解决办法
2万
查看次数

go html/template 中的可选模板?

给定一组模板,例如:

布局.tpl

<html>
<head>
<title>Some title</title>
{{template extracss}}
</head>
<body>
<h1>Page title</h1>
{{template content .}}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

主页.tpl

{{define "content"}}
<p>page content goes here</p>
{{end}}
Run Code Online (Sandbox Code Playgroud)

编辑.tpl

{{define "content"}}
<form>form content goes here</form>
{{end}}

{{define "extracss"}}<style>body{background:pink}</style>{{end}}
Run Code Online (Sandbox Code Playgroud)

使用它来渲染模板:

func Render(w http.ResponseWriter, tmpname string, data interface{}) {

    t, err := template.ParseFiles("views/layout.tpl", "views/"+tmpname+".tpl")
    // parse error
    if err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
    }

    if err := t.Execute(w, data); err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
    }
}
Run Code Online (Sandbox Code Playgroud)

edit.tpl 将正确呈现,因为它定义了“extracss”,而 home.tpl 将不会正确呈现,因为模板解析器正确地说“没有这样的模板“extracss””。

那么我将使用什么机制来允许使用“可选”模板? …

templates go

5
推荐指数
1
解决办法
2214
查看次数

标签 统计

go ×1

meteor ×1

templates ×1