//CheckboxTag builds a checkbox from the options passed
182579
func (f Form) CheckboxTag(opts tags.Options) *tags.Tag {
	opts["type"] = "checkbox"

	value := opts["value"]
	delete(opts, "value")

	checked := opts["checked"]
	delete(opts, "checked")
	if checked == nil {
		checked = "true"
	}
	opts["value"] = checked

	unchecked := opts["unchecked"]
	delete(opts, "unchecked")

	hl := opts["hide_label"]
	delete(opts, "hide_label")

	if opts["tag_only"] == true {
		delete(opts, "label")
		ct := f.InputTag(opts)
		ct.Checked = template.HTMLEscaper(value) == template.HTMLEscaper(checked)
		return ct
	}

	tag := tags.New("label", tags.Options{})
	ct := f.InputTag(opts)
	ct.Checked = template.HTMLEscaper(value) == template.HTMLEscaper(checked)
	tag.Append(ct)

	if opts["name"] != nil && unchecked != nil {
		tag.Append(tags.New("input", tags.Options{
			"type":  "hidden",
			"name":  opts["name"],
			"value": unchecked,
		}))
	}

	if opts["label"] != nil && hl == nil {
		label := fmt.Sprint(opts["label"])
		delete(opts, "label")
		tag.Append(" " + label)
	}
	return tag
}
820447
func ValidateTag(tag string) ([]string, error) {
	ltag := strings.ToLower(tag)
	if !validTagRe.MatchString(ltag) {
		return nil, fmt.Errorf("invalid tag: %q", tag)
	}
	ltags := strings.Split(ltag, ":")
	return ltags, nil
}
773963
func (c *Charm) Tag() names.Tag {
	return names.NewCharmTag(c.URL().String())
}
109401
func (s *DjangoEngine) RegisterTag(tagName string, parserFn TagParser) error {
	fn := func(doc *pongo2.Parser, start *pongo2.Token, arguments *pongo2.Parser) (pongo2.INodeTag, *pongo2.Error) {
		t, err := parserFn((*Parser)(doc), (*Token)(start), (*Parser)(arguments))
		return t, (*pongo2.Error)(err)
	}

	return pongo2.RegisterTag(tagName, fn)
}
1254474
func (r *Reader) CheckTag(expectTag byte) (tag byte) {
	tag = r.readByte()
	if tag != expectTag {
		unexpectedTag(tag, []byte{expectTag})
	}
	return
}
677731
func (s *handler) AttachTag(ref vim.ManagedObjectReference, tag vim.VslmTagEntry) vim.BaseMethodFault {
	t := s.findTag(tag)
	if t == nil {
		return new(vim.NotFound)
	}
	s.Association[t.ID][internal.AssociatedObject(ref)] = true
	return nil
}
987964
func NewSelectTag(opts tags.Options) *tags.Tag {
	so := parseSelectOptions(opts)
	selected := opts["value"]
	delete(opts, "value")

	// Transform selected value(s) into an empty map with values as keys
	// (faster lookup than slice / array)
	selectedMap := make(map[interface{}]struct{})

	multiple, ok := opts["multiple"].(bool)
	if multiple && ok {
		// Set nil to use the empty attribute notation
		opts["multiple"] = nil

		rv := reflect.ValueOf(selected)
		if rv.Kind() == reflect.Ptr {
			rv = rv.Elem()
		}
		if rv.Kind() == reflect.Array || rv.Kind() == reflect.Slice {
			for i := 0; i < rv.Len(); i++ {
				x := rv.Index(i).Interface()
				if s, ok := x.(Selectable); ok {
					// Use Selectable value as the selected value
					x = s.SelectValue()
				}
				selectedMap[template.HTMLEscaper(x)] = struct{}{}
			}
		} else {
			// Set unique value as a map key
			selectedMap[template.HTMLEscaper(selected)] = struct{}{}
		}
	} else {
		if s, ok := selected.(Selectable); ok {
			selected = s.SelectValue()
		}
		// Set unique value as a map key
		selectedMap[template.HTMLEscaper(selected)] = struct{}{}
	}

	delete(opts, "tag_only")

	st := &SelectTag{
		Tag:                tags.New("select", opts),
		SelectOptions:      so,
		SelectedValue:      selected,
		selectedValueCache: selectedMap,
	}

	for _, x := range st.SelectOptions {
		if _, ok := st.selectedValueCache[template.HTMLEscaper(x.Value)]; ok {
			x.Selected = true
		}
		st.Append(x.String())
	}

	return st.Tag
}
318372
func (c *TagCache) AddTag(ctx context.Context, pin common.Pin, tag string) error {
	if err := common.ValidatePin(pin, common.AnyHash); err != nil {
		return err
	}
	if err := common.ValidateInstanceTag(tag); err != nil {
		return err
	}

	c.lock.Lock()
	defer c.lock.Unlock()

	if c.addedTags == nil {
		c.addedTags = make(map[tagKey]*messages.TagCache_Entry, 1)
	}

	// 'Save' will merge this into 'c.cache' before dumping to disk.
	c.addedTags[makeTagKey(pin.PackageName, tag)] = &messages.TagCache_Entry{
		Service:    c.service,
		Package:    pin.PackageName,
		Tag:        tag,
		InstanceId: pin.InstanceID,
	}

	return nil
}
1116504
func validateTag(rawRepo string) (string, error) {
	_, err := reference.ParseNormalizedNamed(rawRepo)
	if err != nil {
		return "", err
	}

	return rawRepo, nil
}
975466
func (c *Manager) DeleteTag(ctx context.Context, tag *Tag) error {
	url := internal.URL(c, internal.TagPath).WithID(tag.ID)
	return c.Do(ctx, url.Request(http.MethodDelete), nil)
}
632303
func (ctx *Context) ActionTag(fieldName string) string {
	ctx.newAction()
	if ctx.route.routeType == StructPtrRoute || ctx.route.routeType == StructRoute {
		tp := ctx.callArgs[0].Type()
		if tp.Kind() == reflect.Ptr {
			tp = tp.Elem()
		}
		field, ok := tp.FieldByName(fieldName)
		if !ok {
			return ""
		}
		return string(field.Tag)
	}
	return ""
}
1044172
func (f *Field) RemoveTag(tag string) FieldInterface {
	delete(f.tag, tag)
	return f
}
878096
func (win *Window) CheckboxText(text string, active *bool) bool {
	state, bounds, fitting := win.widget()
	if fitting != nil {
		fitting(toggleWidth(text, toggleCheck, &win.ctx.Style.Checkbox, win.ctx.Style.Font))
	}
	if !state {
		return false
	}
	in := win.inputMaybe(state)
	old_active := *active
	*active = doToggle(win, bounds, *active, text, toggleCheck, &win.ctx.Style.Checkbox, in, win.ctx.Style.Font)
	return *active != old_active
}
737162
func (f Form) HiddenTag(opts tags.Options) *tags.Tag {
	opts["type"] = "hidden"
	return tags.New("input", opts)
}
383470
func (r *Reader) CheckTags(expectTags []byte) (tag byte) {
	tag = r.readByte()
	if bytes.IndexByte(expectTags, tag) == -1 {
		unexpectedTag(tag, expectTags)
	}
	return
}
1110188
func (p Paginator) Tag(opts Options) (*Tag, error) {
	// return an empty div if there is only 1 page
	if p.TotalPages <= 1 {
		return New("div", Options{}), nil
	}

	path, class, wing := extractBaseOptions(opts)
	opts["class"] = strings.Join([]string{class, "pagination"}, " ")

	t := New("ul", opts)

	barLength := wing*2 + 1
	center := wing + 1
	loopStart := 1
	loopEnd := p.TotalPages

	li, err := p.addPrev(opts, path)
	if err != nil {
		return t, errors.WithStack(err)
	}
	t.Append(li)

	if p.TotalPages > barLength {
		loopEnd = barLength - 2 // range 1 ~ center
		if p.Page > center {    /// range center
			loopStart = p.Page - wing + 2
			loopEnd = loopStart + barLength - 5
			li, err := pageLI("1", 1, path, p)
			if err != nil {
				return t, errors.WithStack(err)
			}
			t.Append(li)
			t.Append(pageLIDummy())
		}
		if p.Page > (p.TotalPages - wing - 1) {
			loopEnd = p.TotalPages
			loopStart = p.TotalPages - barLength + 3
		}
	}

	for i := loopStart; i <= loopEnd; i++ {
		li, err := pageLI(strconv.Itoa(i), i, path, p)
		if err != nil {
			return t, errors.WithStack(err)
		}
		t.Append(li)
	}

	if p.TotalPages > loopEnd {
		t.Append(pageLIDummy())
		label := strconv.Itoa(p.TotalPages)
		li, err := pageLI(label, p.TotalPages, path, p)
		if err != nil {
			return t, errors.WithStack(err)
		}
		t.Append(li)
	}

	li, err = p.addNext(opts, path)
	if err != nil {
		return t, errors.WithStack(err)
	}
	t.Append(li)

	return t, nil
}
421877
func (f FormFor) InputTag(field string, opts tags.Options) *tags.Tag {
	f.buildOptions(field, opts)
	f.addFormatTag(field, opts)
	return f.Form.InputTag(opts)
}