Documentation ¶
Index ¶
- Variables
- func ActionContent2Commits(act Actioner) *repository.PushCommits
- func ActionIcon(opType activities_model.ActionType) string
- func AssetFS() *assetfs.LayeredFS
- func Avatar(ctx context.Context, item any, others ...any) template.HTML
- func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...any) template.HTML
- func AvatarByEmail(ctx context.Context, email, name string, others ...any) template.HTML
- func AvatarHTML(src string, size int, class, name string) template.HTML
- func BuiltinAssets() *assetfs.Layer
- func CustomAssets() *assetfs.Layer
- func DotEscape(raw string) string
- func Eval(tokens ...any) (any, error)
- func FilenameIsImage(filename string) bool
- func HandleTemplateRenderingError(err error) string
- func IsMultilineCommitMessage(msg string) bool
- func ListMailTemplateAssetNames(assets *assetfs.LayeredFS) ([]string, error)
- func ListWebTemplateAssetNames(assets *assetfs.LayeredFS) ([]string, error)
- func Mailer(ctx context.Context) (*texttmpl.Template, *template.Template)
- func MigrationIcon(hostname string) string
- func NewFuncMap() template.FuncMap
- func ReactionToEmoji(reaction string) template.HTML
- func ReloadHTMLTemplates() error
- func RenderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML
- func RenderCommitBody(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML
- func RenderCommitMessage(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML
- func RenderCommitMessageLink(ctx context.Context, msg, urlPrefix, urlDefault string, ...) template.HTML
- func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlPrefix, urlDefault string, ...) template.HTML
- func RenderEmoji(ctx context.Context, text string) template.HTML
- func RenderIssueTitle(ctx context.Context, text, urlPrefix string, metas map[string]string) template.HTML
- func RenderLabel(ctx context.Context, label *issues_model.Label) template.HTML
- func RenderLabels(ctx context.Context, labels []*issues_model.Label, repoLink string) template.HTML
- func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML
- func RenderNote(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML
- func RepoAvatar(repo *repo_model.Repository, others ...any) template.HTML
- func Safe(raw string) template.HTML
- func SortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML
- func Str2html(raw string) template.HTML
- func TabSizeClass(ec any, filename string) string
- type Actioner
- type HTMLRender
- type JsonUtils
- type SliceUtils
- type StringUtils
- type TemplateExecutor
Constants ¶
This section is empty.
Variables ¶
var ErrTemplateNotInitialized = errors.New("template system is not initialized, check your log for errors")
Functions ¶
func ActionContent2Commits ¶
func ActionContent2Commits(act Actioner) *repository.PushCommits
ActionContent2Commits converts action content to push commits
func ActionIcon ¶
func ActionIcon(opType activities_model.ActionType) string
ActionIcon accepts an action operation type and returns an icon class name.
func AvatarByAction ¶ added in v1.14.0
func AvatarByAction(ctx context.Context, action *activities_model.Action, others ...any) template.HTML
AvatarByAction renders user avatars from action. args: action, size (int), class (string)
func AvatarByEmail ¶ added in v1.14.0
AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
func AvatarHTML ¶ added in v1.14.0
AvatarHTML creates the HTML for an avatar
func BuiltinAssets ¶ added in v1.20.0
func CustomAssets ¶ added in v1.20.0
func DotEscape ¶ added in v1.16.5
DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls
func Eval ¶ added in v1.20.0
Eval the expression and return the result, see the comment of eval.Expr for details. To use this helper function in templates, pass each token as a separate parameter.
{{ $int64 := Eval $var "+" 1 }} {{ $float64 := Eval $var "+" 1.0 }}
Golang's template supports comparable int types, so the int64 result can be used in later statements like {{if lt $int64 10}}
func FilenameIsImage ¶ added in v1.20.0
func HandleTemplateRenderingError ¶ added in v1.20.0
func IsMultilineCommitMessage ¶ added in v1.4.0
IsMultilineCommitMessage checks to see if a commit message contains multiple lines.
func ListMailTemplateAssetNames ¶ added in v1.20.0
func ListWebTemplateAssetNames ¶ added in v1.20.0
func MigrationIcon ¶ added in v1.10.0
MigrationIcon returns a SVG name matching the service an issue/comment was migrated from
func NewFuncMap ¶
NewFuncMap returns functions for injecting to templates
func ReactionToEmoji ¶ added in v1.12.0
ReactionToEmoji renders emoji for use in reactions
func ReloadHTMLTemplates ¶ added in v1.20.0
func ReloadHTMLTemplates() error
func RenderCodeBlock ¶ added in v1.17.4
RenderCodeBlock renders "`…`" as highlighted "<code>" block. Intended for issue and PR titles, these containers should have styles for "<code>" elements
func RenderCommitBody ¶ added in v1.4.0
func RenderCommitBody(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML
RenderCommitBody extracts the body of a commit message without its title.
func RenderCommitMessage ¶
func RenderCommitMessage(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML
RenderCommitMessage renders commit message with XSS-safe and special links.
func RenderCommitMessageLink ¶ added in v1.3.0
func RenderCommitMessageLink(ctx context.Context, msg, urlPrefix, urlDefault string, metas map[string]string) template.HTML
RenderCommitMessageLink renders commit message as a XXS-safe link to the provided default url, handling for special links.
func RenderCommitMessageLinkSubject ¶ added in v1.10.0
func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlPrefix, urlDefault string, metas map[string]string) template.HTML
RenderCommitMessageLinkSubject renders commit message as a XXS-safe link to the provided default url, handling for special links without email to links.
func RenderEmoji ¶ added in v1.12.0
RenderEmoji renders html text with emoji post processors
func RenderIssueTitle ¶ added in v1.14.0
func RenderIssueTitle(ctx context.Context, text, urlPrefix string, metas map[string]string) template.HTML
RenderIssueTitle renders issue/pull title with defined post processors
func RenderLabel ¶ added in v1.19.0
RenderLabel renders a label
func RenderLabels ¶ added in v1.20.0
func RenderMarkdownToHtml ¶ added in v1.20.0
func RenderNote ¶ added in v1.9.0
RenderNote renders the contents of a git-notes file as a commit message.
func RepoAvatar ¶ added in v1.14.0
func RepoAvatar(repo *repo_model.Repository, others ...any) template.HTML
RepoAvatar renders repo avatars. args: repo, size(int), class (string)
func TabSizeClass ¶ added in v1.20.0
Types ¶
type Actioner ¶
type Actioner interface { GetOpType() activities_model.ActionType GetActUserName() string GetRepoUserName() string GetRepoName() string GetRepoPath() string GetRepoLink() string GetBranch() string GetContent() string GetCreate() time.Time GetIssueInfos() []string }
Actioner describes an action
type HTMLRender ¶ added in v1.20.0
type HTMLRender struct {
// contains filtered or unexported fields
}
func HTMLRenderer ¶ added in v1.6.0
func HTMLRenderer() *HTMLRender
HTMLRenderer init once and returns the globally shared html renderer
func (*HTMLRender) CompileTemplates ¶ added in v1.20.0
func (h *HTMLRender) CompileTemplates() error
func (*HTMLRender) TemplateLookup ¶ added in v1.20.0
func (h *HTMLRender) TemplateLookup(name string) (TemplateExecutor, error)
type JsonUtils ¶ added in v1.20.0
type JsonUtils struct{} //nolint:revive
func NewJsonUtils ¶ added in v1.20.0
func NewJsonUtils() *JsonUtils
func (*JsonUtils) EncodeToString ¶ added in v1.20.0
func (*JsonUtils) PrettyIndent ¶ added in v1.20.0
type SliceUtils ¶ added in v1.20.0
type SliceUtils struct{}
func NewSliceUtils ¶ added in v1.20.0
func NewSliceUtils() *SliceUtils
func (*SliceUtils) Contains ¶ added in v1.20.0
func (su *SliceUtils) Contains(s, v any) bool
type StringUtils ¶ added in v1.20.0
type StringUtils struct{}
func NewStringUtils ¶ added in v1.20.0
func NewStringUtils() *StringUtils
func (*StringUtils) Contains ¶ added in v1.20.0
func (su *StringUtils) Contains(s, substr string) bool
func (*StringUtils) EllipsisString ¶ added in v1.20.0
func (su *StringUtils) EllipsisString(s string, max int) string
func (*StringUtils) HasPrefix ¶ added in v1.20.0
func (su *StringUtils) HasPrefix(s, prefix string) bool
func (*StringUtils) Join ¶ added in v1.20.0
func (su *StringUtils) Join(a []string, sep string) string
func (*StringUtils) Split ¶ added in v1.20.0
func (su *StringUtils) Split(s, sep string) []string
type TemplateExecutor ¶ added in v1.20.0
type TemplateExecutor scopedtmpl.TemplateExecutor