本文整理汇总了Golang中html/template.HTMLAttr函数的典型用法代码示例。如果您正苦于以下问题:Golang HTMLAttr函数的具体用法?Golang HTMLAttr怎么用?Golang HTMLAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了HTMLAttr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetAssetUrl

func (s *SprocketsDirectory) GetAssetUrl(name string) (template.HTMLAttr, error) {
    src, ok := s.assets[name]
    if !ok {
        return template.HTMLAttr(s.prefix + "__NOT_FOUND__" + name), errors.New("Asset not found: " + name)
    }
    return template.HTMLAttr(s.prefix + src), nil
}

开发者ID:vinays,项目名称:goodies,代码行数:7,代码来源:prebuilt_sprockets.go

示例2: NewTagEntry

// NewTagEntry creates a new ArchiveEntry for the given values.
func NewTagEntry(file, title string) *TagEntry {
    url := file + ".html"

    // Not all pages have a metadata title defined.
    // Use the page url instead, after we prettify it a bit.
    if len(title) == 0 {
        title = file

        if strings.HasSuffix(title, "/index") {
            title, _ = filepath.Split(title)
        }

        if title == "/" {
            title = "Home"
        }
    }

    // If the url ends with /index.html, we strip off the index part.
    // It just takes up unnecessary bytes in the output and
    // `foo/bar/` looks better than `foo/bar/index.html`.
    if strings.HasSuffix(url, "/index.html") {
        url, _ = filepath.Split(url)
    }

    te := new(TagEntry)
    te.Url = template.HTMLAttr(url)
    te.Title = template.HTMLAttr(title)
    return te
}

开发者ID:jteeuwen,项目名称:blargh,代码行数:30,代码来源:tags.go

示例3: GetAssetUrl

func (s *SprocketsServer) GetAssetUrl(name string) (template.HTMLAttr, error) {
    src, ok := s.assets[name]
    if !ok {
        return template.HTMLAttr(s.baseUrl + "__NOT_FOUND__" + name), errors.New("Asset not found: " + name)
    }
    return template.HTMLAttr(s.baseUrl + src), nil
}

开发者ID:vinays,项目名称:goodies,代码行数:7,代码来源:remote_sprockets.go

示例4: InjectRender

func InjectRender(c *web.C, h http.Handler) http.Handler {
    fn := func(w http.ResponseWriter, r *http.Request) {

        c.Env["render"] = render.New(render.Options{
            Directory:  "views",
            Layout:     "",
            Extensions: []string{".tmpl"},
            Funcs: []template.FuncMap{template.FuncMap{
                "classIfHere": func(path, class string) template.HTMLAttr {
                    if r.URL.Path == path {
                        return template.HTMLAttr(fmt.Sprintf(`class="%s"`, class))
                    }
                    return template.HTMLAttr("")
                },
                "date": func(date time.Time) string {
                    return date.Format("January 2, 2006")
                },
                "checkIfInArray": func(x string, slice []string) template.HTMLAttr {
                    for _, y := range slice {
                        if x == y {
                            return template.HTMLAttr("checked")
                        }
                    }
                    return template.HTMLAttr("")
                },
            }},
        })

        h.ServeHTTP(w, r)

    }

    return http.HandlerFunc(fn)
}

开发者ID:ignaciocarvajal,项目名称:go-portafolio,代码行数:34,代码来源:render.go

示例5: EchoSelectSelected

func EchoSelectSelected(option string, value interface{}) htmlTemplate.HTMLAttr {
    if option == fmt.Sprint(value) {
        return htmlTemplate.HTMLAttr(" selected")
    }

    return htmlTemplate.HTMLAttr("")
}

开发者ID:peteraba,项目名称:go-blah,代码行数:7,代码来源:select_selected.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng