本文整理匯總了Golang中github.com/daaku/rell/rellenv.Env類的典型用法代碼示例。如果您正苦於以下問題:Golang Env類的具體用法?Golang Env怎麽用?Golang Env使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Env類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FromBase64
// Create a new Object from Base64 JSON encoded data.
func (p *Parser) FromBase64(ctx context.Context, env *rellenv.Env, b64 string) (*Object, error) {
jsonBytes, err := base64.URLEncoding.DecodeString(fixPadding(b64))
if err != nil {
return nil, fmt.Errorf(
"Failed base64 decode of string \"%s\" with error: %s", b64, err)
}
var strSlices [][]interface{}
err = json.Unmarshal(jsonBytes, &strSlices)
if err != nil {
return nil, fmt.Errorf(
"Failed json unmarshal string %s with error %s", string(jsonBytes), err)
}
object := &Object{
context: ctx,
env: env,
static: p.Static,
}
for _, row := range strSlices {
if len(row) != 2 {
return nil, fmt.Errorf("Got more than two elements in pair: %v", row)
}
if row[0] == nil {
return nil, fmt.Errorf("First element in pair is null: %v", row)
}
key := fmt.Sprint(row[0])
val := ""
switch t := row[1].(type) {
case nil:
object.skipGenerate = append(object.skipGenerate, key)
continue
case float64:
val = fmt.Sprint(uint64(t))
default:
val = fmt.Sprint(t)
}
object.AddPair(key, val)
}
if object.shouldGenerate("og:url") {
url := env.AbsoluteURL("/rog/" + b64).String()
object.AddPair("og:url", url)
}
err = object.generateDefaults()
if err != nil {
return nil, err
}
return object, nil
}
示例2: renderObject
// Render a document for the Object.
func renderObject(ctx context.Context, env *rellenv.Env, s *static.Handler, o *og.Object) h.HTML {
var title, header h.HTML
if o.Title() != "" {
title = &h.Title{h.String(o.Title())}
header = &h.H1{
Inner: &h.A{
HREF: o.URL(),
Inner: h.String(o.Title()),
},
}
}
return &h.Document{
Inner: h.Frag{
&h.Head{
Inner: h.Frag{
&h.Meta{Charset: "utf-8"},
title,
&static.LinkStyle{
HREF: view.DefaultPageConfig.Style,
},
renderMeta(o),
},
},
&h.Body{
Class: "container",
Inner: h.Frag{
&h.Div{ID: "fb-root"},
view.DefaultPageConfig.GA,
&fb.Init{
URL: env.SdkURL(),
AppID: rellenv.FbApp(ctx).ID(),
},
&h.Div{
Class: "row",
Inner: h.Frag{
&h.Div{
Class: "span8",
Inner: header,
},
&h.Div{
Class: "span4",
Inner: &h.A{
Class: "btn btn-info pull-right",
HREF: o.LintURL(),
Inner: h.Frag{
&h.I{Class: "icon-warning-sign icon-white"},
h.String(" Debugger"),
},
},
},
},
},
&h.Div{
Class: "row",
Inner: h.Frag{
&h.Div{
Class: "span6",
Inner: h.Frag{
renderMetaTable(o),
&h.Iframe{
Class: "like",
Src: o.LikeURL(),
},
},
},
&h.Div{
Class: "span6",
Inner: &h.A{
HREF: o.ImageURL(),
Inner: &h.Img{
Src: o.ImageURL(),
Alt: o.Title(),
},
},
},
},
},
},
},
},
}
}
示例3: redirectURI
func redirectURI(c *rellenv.Env) string {
return c.AbsoluteURL(Path + resp).String()
}