Add user profile macro

This commit is contained in:
Manuel Rüger
2023-05-22 20:50:26 +02:00
parent d67cc63871
commit 6a63913a1e
2 changed files with 25 additions and 2 deletions

View File

@@ -136,7 +136,11 @@ func templates(api *confluence.API) (*template.Template, error) {
`ac:link:user`: text(
`{{ with .Name | user }}`,
/**/ `<ac:link>`,
/**/ `<ri:user ri:account-id="{{ .AccountID }}"/>`,
/**/ `{{ with .AccountID }}`,
/****/ `<ri:user ri:account-id="{{ .AccountID }}" />`,
/**/ `{{ else }}`,
/****/ `<ri:user ri:userkey="{{ .UserKey }}" />`,
/**/ `{{ end }}`,
/**/ `</ac:link>`,
`{{ else }}`,
/**/ `{{ .Name }}`,
@@ -319,6 +323,22 @@ func templates(api *confluence.API) (*template.Template, error) {
`</ac:structured-macro>`,
),
/* https://confluence.atlassian.com/conf59/user-profile-macro-792499223.html */
`ac:profile`: text(
`{{ with .Name | user }}`,
`<ac:structured-macro ac:name="profile">{{printf "\n"}}`,
`<ac:parameter ac:name="user">{{printf "\n"}}`,
`{{ with .AccountID }}`,
/**/ `<ri:user ri:account-id="{{ .AccountID }}" />{{printf "\n"}}`,
`{{ else }}`,
/**/ `<ri:user ri:userkey="{{ .UserKey }}" />`,
`{{ end }}`,
`</ac:parameter>{{printf "\n"}}`,
`</ac:structured-macro>{{printf "\n"}}`,
`{{ end }}`,
),
// TODO(seletskiy): more templates here
} {
templates, err = templates.New(name).Parse(body)