github.com/kotovmak/go-admin@v1.1.1/template/components/link.go (about)

     1  package components
     2  
     3  import (
     4  	"html/template"
     5  
     6  	"github.com/kotovmak/go-admin/template/types"
     7  )
     8  
     9  type LinkAttribute struct {
    10  	Name       string
    11  	URL        string
    12  	Class      template.HTML
    13  	Title      template.HTML
    14  	Attributes template.HTMLAttr
    15  	Content    template.HTML
    16  	types.Attribute
    17  }
    18  
    19  func (compo *LinkAttribute) OpenInNewTab() types.LinkAttribute {
    20  	compo.Class += " new-tab-link"
    21  	return compo
    22  }
    23  
    24  func (compo *LinkAttribute) SetURL(value string) types.LinkAttribute {
    25  	compo.URL = value
    26  	return compo
    27  }
    28  
    29  func (compo *LinkAttribute) SetClass(class template.HTML) types.LinkAttribute {
    30  	compo.Class = class
    31  	return compo
    32  }
    33  
    34  func (compo *LinkAttribute) SetAttributes(attr template.HTMLAttr) types.LinkAttribute {
    35  	compo.Attributes = attr
    36  	return compo
    37  }
    38  
    39  func (compo *LinkAttribute) NoPjax() types.LinkAttribute {
    40  	compo.Class += " no-pjax"
    41  	return compo
    42  }
    43  
    44  func (compo *LinkAttribute) SetTabTitle(value template.HTML) types.LinkAttribute {
    45  	compo.Title = value
    46  	return compo
    47  }
    48  
    49  func (compo *LinkAttribute) SetContent(value template.HTML) types.LinkAttribute {
    50  	compo.Content = value
    51  	return compo
    52  }
    53  
    54  func (compo *LinkAttribute) GetContent() template.HTML {
    55  	return ComposeHtml(compo.TemplateList, compo.Separation, *compo, "link")
    56  }