good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
temple
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
util
temple
Commits
1ee9332f
Commit
1ee9332f
authored
Nov 20, 2022
by
a
Browse files
Options
Downloads
Patches
Plain Diff
a
parent
11ecb259
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/mapn/main.go
+27
-0
27 additions, 0 deletions
examples/mapn/main.go
examples/mapn/mapn.tmpl
+7
-0
7 additions, 0 deletions
examples/mapn/mapn.tmpl
lib/sanctum/sanctum.go
+6
-2
6 additions, 2 deletions
lib/sanctum/sanctum.go
temple.go
+6
-1
6 additions, 1 deletion
temple.go
with
46 additions
and
3 deletions
examples/mapn/main.go
0 → 100644
+
27
−
0
View file @
1ee9332f
package
main
//go:generate go run .
import
(
"log"
"gfx.cafe/util/temple"
"gfx.cafe/util/temple/lib/sanctum"
)
func
main
()
{
temple
.
RegisterTemplateFile
(
"mapn.tmpl"
)
temple
.
Prepare
(
&
sanctum
.
Prayer
{
Input
:
"mapn"
,
Obj
:
map
[
string
]
any
{
"Count"
:
3
,
},
Args
:
nil
,
PackagePath
:
"maps"
,
PackageName
:
"maps"
,
FileName
:
"map2.go"
,
})
err
:=
temple
.
Pray
()
if
err
!=
nil
{
log
.
Println
(
err
)
}
}
This diff is collapsed.
Click to expand it.
examples/mapn/mapn.tmpl
0 → 100644
+
7
−
0
View file @
1ee9332f
import {
"sync"
}
type Map{{.Count}}
This diff is collapsed.
Click to expand it.
lib/sanctum/sanctum.go
+
6
−
2
View file @
1ee9332f
...
...
@@ -2,6 +2,7 @@ package sanctum
import
(
"fmt"
"log"
"path/filepath"
"strings"
"text/template"
...
...
@@ -116,12 +117,15 @@ func (t *Sanctum) Pray() error {
if
err
!=
nil
{
return
fmt
.
Errorf
(
"exec tmpl=%s obj=%+v args=%v err=%w"
,
v
.
Input
,
v
.
Obj
,
v
.
Args
,
err
)
}
t
.
fs
.
MkdirAll
(
v
.
PackagePath
,
0777
)
err
=
t
.
fs
.
MkdirAll
(
v
.
PackagePath
,
0777
)
if
err
!=
nil
{
log
.
Printf
(
"WARNING: mkdirall failed :%s"
,
err
)
}
file
,
err
:=
t
.
fs
.
Create
(
filepath
.
Join
(
v
.
PackagePath
,
v
.
FileName
))
defer
file
.
Close
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"openfile tmpl=%s obj=%+v args=%v err=%w"
,
v
.
Input
,
v
.
Obj
,
v
.
Args
,
err
)
}
defer
file
.
Close
()
err
=
file
.
Truncate
(
0
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"truncfile tmpl=%s obj=%+v args=%v err=%w"
,
v
.
Input
,
v
.
Obj
,
v
.
Args
,
err
)
...
...
This diff is collapsed.
Click to expand it.
temple.go
+
6
−
1
View file @
1ee9332f
...
...
@@ -5,8 +5,13 @@ import (
"gfx.cafe/util/temple/lib/sanctum"
)
var
t
=
sanctum
.
New
(
"."
)
var
Sanctum
=
t
var
t
*
sanctum
.
Sanctum
func
init
()
{
Sanctum
=
sanctum
.
New
(
"./"
)
t
=
Sanctum
}
var
curPreset
preset
.
Preset
...
...
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