2019-03-13 04:14:30 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
type text struct {
|
2022-01-01 11:08:08 -08:00
|
|
|
props Properties
|
2022-01-01 11:09:52 -08:00
|
|
|
env Environment
|
2021-10-06 12:50:52 -07:00
|
|
|
content string
|
2019-03-13 04:14:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2020-11-12 00:43:32 -08:00
|
|
|
// TextProperty represents text to write
|
2019-03-13 04:14:30 -07:00
|
|
|
TextProperty Property = "text"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (t *text) enabled() bool {
|
2021-12-26 10:36:04 -08:00
|
|
|
textProperty := t.props.getOneOfString(TextProperty, SegmentTemplate, "!!text property not defined!!")
|
2021-08-09 20:48:44 -07:00
|
|
|
template := &textTemplate{
|
|
|
|
Template: textProperty,
|
|
|
|
Context: t,
|
|
|
|
Env: t.env,
|
|
|
|
}
|
2022-01-12 14:39:34 -08:00
|
|
|
if text, err := template.render(); err == nil {
|
|
|
|
t.content = text
|
|
|
|
return len(t.content) > 0
|
|
|
|
}
|
|
|
|
return false
|
2021-10-06 12:50:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *text) string() string {
|
|
|
|
return t.content
|
2019-03-13 04:14:30 -07:00
|
|
|
}
|
|
|
|
|
2022-01-01 11:09:52 -08:00
|
|
|
func (t *text) init(props Properties, env Environment) {
|
2019-03-13 04:14:30 -07:00
|
|
|
t.props = props
|
|
|
|
t.env = env
|
|
|
|
}
|