| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // package wlabel -- WUI метка
- package wlabel
- import (
- "strings"
- "gitp78su.ipnodns.ru/svi/kern/wui/wtext"
- . "gitp78su.ipnodns.ru/svi/kern/wui/wtypes"
- "gitp78su.ipnodns.ru/svi/kern/wui/wwidget"
- )
- // WuiLabel -- WUI метка
- type WuiLabel struct {
- IWuiWidget
- text IWuiText
- }
- // NewWuiLabel -- возвращает новую метку
- func NewWuiLabel(text string) *WuiLabel {
- sf := &WuiLabel{
- IWuiWidget: wwidget.NewWuiWidget(),
- text: wtext.NewWuiText(text),
- }
- _ = IWuiLabel(sf)
- return sf
- }
- // Text -- возвращает текст метки
- func (sf *WuiLabel) Text() IWuiText {
- return sf.text
- }
- const (
- strBeg = `<div id="{.id}">{.txt}</div>`
- )
- // Html -- возвращает HTML-представление текста
- func (sf *WuiLabel) Html() string {
- strRes := strings.ReplaceAll(strBeg, "{.id}", sf.Id())
- strRes = strings.ReplaceAll(strRes, "{.txt}", sf.text.Get())
- return strRes
- }
|