如何在golang Beego模板中应用多个切片的范围?

时间:2016-04-28 06:33:51

标签: go beego go-templates

我有一个结构,包含两个大小相同的切片,将传递给模板。

type V struct {
    Process         []string
    ProcessType     []string
}

我需要在相同的范围内迭代切片。在golang(没有框架)中,我们可以按照以下方式执行此操作

//I know all of you know this. Added for better understanding of my problem.
{{range $i, $e := .Process}} 
    {{.}} 
    {{index $.ProcessType $i}}
{{end}} 

我们可以像这样在一个切片上应用范围

{{range $key, $val := .vm.Process}} //this.Data["vm"] = V (Struct V is passed as vm to the template)
    {{$val}}
{{end}}

如何在此范围内包含切片ProcessType?

0 个答案:

没有答案
相关问题