本文整理汇总了Golang中github.com/FooSoft/goldsmith.File.SetValue方法的典型用法代码示例。如果您正苦于以下问题:Golang File.SetValue方法的具体用法?Golang File.SetValue怎么用?Golang File.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/FooSoft/goldsmith.File
的用法示例。
在下文中一共展示了File.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Process
func (c *collection) Process(ctx goldsmith.Context, f goldsmith.File) error {
c.mtx.Lock()
defer func() {
f.SetValue(c.groupsKey, c.groups)
c.files = append(c.files, f)
c.mtx.Unlock()
}()
coll, ok := f.Value(c.collKey)
if !ok {
return nil
}
var collStrs []string
switch t := coll.(type) {
case string:
collStrs = append(collStrs, t)
case []string:
collStrs = append(collStrs, t...)
}
for _, collStr := range collStrs {
files, _ := c.groups[collStr]
files = append(files, f)
c.groups[collStr] = files
}
return nil
}
示例2: Process
func (lay *layout) Process(ctx goldsmith.Context, f goldsmith.File) error {
var buff bytes.Buffer
if _, err := buff.ReadFrom(f); err != nil {
return err
}
if _, ok := f.Value(lay.layoutKey); ok {
f.SetValue(lay.contentKey, template.HTML(buff.Bytes()))
lay.filesMtx.Lock()
lay.files = append(lay.files, f)
lay.filesMtx.Unlock()
} else {
ctx.DispatchFile(f)
}
return nil
}
示例3: Process
func (t *tags) Process(ctx goldsmith.Context, f goldsmith.File) error {
tagState := &tagState{Info: t.info}
t.mtx.Lock()
defer func() {
f.SetValue(t.stateKey, tagState)
t.files = append(t.files, f)
t.mtx.Unlock()
}()
tags, ok := f.Value(t.tagsKey)
if !ok {
return nil
}
tagsArr, ok := tags.([]interface{})
if !ok {
return nil
}
for _, tag := range tagsArr {
tagStr, ok := tag.(string)
if !ok {
continue
}
tagState.Tags = append(tagState.Tags, tagStr)
item, ok := t.info[tagStr]
item.Files = append(item.Files, f)
if !ok {
item.SafeName = safeTag(tagStr)
item.RawName = tagStr
item.Path = t.tagPagePath(tagStr)
}
t.info[tagStr] = item
}
sort.Strings(tagState.Tags)
return nil
}