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


Golang TagNode.Classes方法代码示例

本文整理汇总了Golang中offend/me/uk/thiy/common.TagNode.Classes方法的典型用法代码示例。如果您正苦于以下问题:Golang TagNode.Classes方法的具体用法?Golang TagNode.Classes怎么用?Golang TagNode.Classes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在offend/me/uk/thiy/common.TagNode的用法示例。


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

示例1: makeCol

func makeCol(in common.TagNode) common.TagNode {
	if in.Tag != "col" {
		panic("attempt to make a bootstrap col out of a non-col")
	}

	in.Tag = "div"

	var attrs []common.Attribute

	for _, attr := range in.Attributes {
		include := true

		for _, size := range bsSizes {
			if attr.Name == size {
				in.Classes = append(in.Classes, "col-"+attr.Name+"-"+attr.Value)
				include = false
			}
		}

		if include {
			attrs = append(attrs, attr)
		}
	}

	in.Attributes = attrs

	return in
}
开发者ID:stilvoid,项目名称:thiy,代码行数:28,代码来源:bootstrap.go

示例2: makeFormControl

func makeFormControl(in common.TagNode) (out common.TagNode) {
	if in.Tag != "input" && in.Tag != "select" {
		panic("attempt to make a bootstrap from control out of a non-input")
	}

	out.Tag = "div"

	out.Classes = []string{"form-group"}

	in.Classes = append(in.Classes, "form-control")

	var attrs []common.Attribute

	for _, attr := range in.Attributes {
		include := true

		if attr.Name == "label" {
			labelNode := common.TagNode{
				Tag:     "label",
				Classes: []string{"control-label"},
				Content: []common.Node{
					common.TextNode{attr.Value},
				},
			}

			if in.Id != "" {
				labelNode.Attributes = []common.Attribute{
					{"for", in.Id},
				}
			}

			out.Content = append(out.Content, labelNode)

			include = false
		}

		if include {
			attrs = append(attrs, attr)
		}
	}

	in.Attributes = attrs

	if len(in.Content) == 1 {
		if textNode, ok := in.Content[0].(common.TextNode); ok {
			in.Attributes = append(in.Attributes, common.Attribute{"placeholder", textNode.Content})

			in.Content = nil
		}
	}

	out.Content = append(out.Content, in)

	return
}
开发者ID:stilvoid,项目名称:thiy,代码行数:55,代码来源:bootstrap.go

示例3: makeRow

func makeRow(in common.TagNode) common.TagNode {
	if in.Tag != "row" {
		panic("attempt to make a bootstrap row out of a non-row")
	}

	in.Tag = "div"

	in.Classes = append(in.Classes, "row")

	return in
}
开发者ID:stilvoid,项目名称:thiy,代码行数:11,代码来源:bootstrap.go

示例4: newElement

func newElement(input string) (common.TagNode, error) {
	var el common.TagNode

	match := elementRe.FindStringSubmatch(input)

	if match == nil {
		return el, fmt.Errorf("Badly-formatted wossname")
	}

	for i, name := range elementNames {
		switch name {
		case "tag":
			el.Tag = match[i]
		case "id":
			el.Id = match[i]
		case "classes":
			if match[i] == "" {
				continue
			}

			el.Classes = strings.Fields(match[i])
		case "attributes":
			if match[i] == "" {
				continue
			}

			var err error

			el.Attributes, err = parseAttributes(match[i])

			if err != nil {
				return el, err
			}
		}

	}

	return el, nil
}
开发者ID:stilvoid,项目名称:thiy,代码行数:39,代码来源:element.go

示例5: makeIcon

func makeIcon(in common.TagNode) common.TagNode {
	if in.Tag != "icon" {
		panic("attempt to make a bootstrap icon out of a non-icon")
	}

	if len(in.Content) != 1 {
		panic("bootstrap icon requires an icon name")
	}

	textNode, ok := in.Content[0].(common.TextNode)

	if !ok {
		panic("bootstrap icon requires an icon name")
	}

	in.Tag = "span"

	in.Classes = append(in.Classes, "glyphicon", "glyphicon-"+textNode.Content)

	in.Content = nil

	return in
}
开发者ID:stilvoid,项目名称:thiy,代码行数:23,代码来源:bootstrap.go


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