当前位置: 首页>>代码示例>>Golang>>正文


Golang File.SetValue方法代码示例

本文整理汇总了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
}
开发者ID:FooSoft,项目名称:goldsmith-plugins,代码行数:29,代码来源:collection.go

示例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
}
开发者ID:FooSoft,项目名称:goldsmith-plugins,代码行数:18,代码来源:layout.go

示例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
}
开发者ID:FooSoft,项目名称:goldsmith-plugins,代码行数:42,代码来源:tags.go


注:本文中的github.com/FooSoft/goldsmith.File.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。