Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
ac12cd52
Commit
ac12cd52
authored
1 month ago
by
Semyon Krestyaninov
Browse files
Options
Downloads
Patches
Plain Diff
add comment
parent
cd13b7f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
template/builder.go
+7
-6
7 additions, 6 deletions
template/builder.go
with
7 additions
and
6 deletions
template/builder.go
+
7
−
6
View file @
ac12cd52
...
...
@@ -18,8 +18,6 @@ type Template interface {
}
type
Builder
struct
{
parseFunc
func
(
data
string
)
(
Template
,
error
)
ctx
context
.
Context
cnt
*
content
.
Content
SpaceID
string
...
...
@@ -31,6 +29,9 @@ type Builder struct {
space
*
spaces
.
Space
environment
*
environments
.
Environment
collection
*
collections
.
Collection
// templateFunc парсит строку и возвращает шаблон для подстановки значений
templateFunc
func
(
data
string
)
(
Template
,
error
)
}
func
NewBuilder
(
cnt
*
content
.
Content
,
space
,
env
,
col
string
)
Builder
{
...
...
@@ -41,7 +42,7 @@ func NewBuilder(cnt *content.Content, space, env, col string) Builder {
EnvID
:
env
,
CollID
:
col
,
}
b
.
pars
eFunc
=
func
(
data
string
)
(
Template
,
error
)
{
b
.
templat
eFunc
=
func
(
data
string
)
(
Template
,
error
)
{
return
text
.
New
(
"main_text"
)
.
Funcs
(
b
.
getFuncs
())
.
Parse
(
data
)
}
return
b
...
...
@@ -55,7 +56,7 @@ func NewHTMLBuilder(cnt *content.Content, space, env, col string) Builder {
EnvID
:
env
,
CollID
:
col
,
}
b
.
pars
eFunc
=
func
(
data
string
)
(
Template
,
error
)
{
b
.
templat
eFunc
=
func
(
data
string
)
(
Template
,
error
)
{
return
html
.
New
(
"main_html"
)
.
Funcs
(
b
.
getFuncs
())
.
Parse
(
data
)
}
return
b
...
...
@@ -112,7 +113,7 @@ func (b *Builder) Context() context.Context {
func
(
b
*
Builder
)
Execute
(
str
string
,
data
...
any
)
(
string
,
error
)
{
buf
:=
new
(
bytes
.
Buffer
)
t
,
err
:=
b
.
pars
eFunc
(
str
)
t
,
err
:=
b
.
templat
eFunc
(
str
)
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -129,7 +130,7 @@ func (b *Builder) ExecuteList(str []string, data ...any) ([]string, error) {
if
tmpl
==
""
{
continue
}
t
,
err
:=
b
.
pars
eFunc
(
tmpl
)
t
,
err
:=
b
.
templat
eFunc
(
tmpl
)
if
err
!=
nil
{
return
[]
string
{},
err
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment