diff --git a/cmd/tht/main.go b/cmd/tht/main.go deleted file mode 100644 index 80844f0..0000000 --- a/cmd/tht/main.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -import ( - "surdeus.su/util/tpp/server" - "os" -) - -func main() { - server.Tool.Run(os.Args[1:]) -} diff --git a/go.mod b/go.mod index 67794c2..22b0b12 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,5 @@ go 1.22.3 require ( github.com/d5/tengo/v2 v2.17.0 - github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2 surdeus.su/core/cli v0.1.2 ) - -require surdeus.su/core/xgo v0.5.0 // indirect diff --git a/go.sum b/go.sum index fb791d2..2b30525 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,4 @@ github.com/d5/tengo/v2 v2.17.0 h1:BWUN9NoJzw48jZKiYDXDIF3QrIVZRm1uV1gTzeZ2lqM= github.com/d5/tengo/v2 v2.17.0/go.mod h1:XRGjEs5I9jYIKTxly6HCF8oiiilk5E/RYXOZ5b0DZC8= -github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2 h1:yEt5djSYb4iNtmV9iJGVday+i4e9u6Mrn5iP64HH5QM= -github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA= -surdeus.su/core/cli v0.0.2 h1:RdHHk3/Fhwxz9PjaE+vTlCuF9KmhrmNUb5y4oqulrYI= -surdeus.su/core/cli v0.0.2/go.mod h1:UKwCmcSX+x7XX9aF3gOaaAaJcJA3gtUmL4vdnM43+fM= surdeus.su/core/cli v0.1.2 h1:qPzjawqPyZsO4Z5SaA1u141recVE65yioA83Qs7Jecs= surdeus.su/core/cli v0.1.2/go.mod h1:r9JtQz3aEJzpYzMaNUNQHJoYkoWKNPi047qhd5uGlmA= -surdeus.su/core/xgo v0.5.0 h1:/Rk3scfFkoSb0qjHRlkUNOp9sr/fd7wAvCiT4fBRo+U= -surdeus.su/core/xgo v0.5.0/go.mod h1:6C/AHbjfvAMvt3TOzLB4eIZ40eU3ahJXtdY+kr4yXoc= diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e098c29 --- /dev/null +++ b/readme.md @@ -0,0 +1,4 @@ +# tpp + +Tengo preprocessor library. + diff --git a/src/check.htm.tpp b/src/check.htm.tpp deleted file mode 100644 index 6674cd9..0000000 --- a/src/check.htm.tpp +++ /dev/null @@ -1,5 +0,0 @@ -
shit
-{{ - pp.print("cock") -}} -
later
diff --git a/src/check/index.htm.tpp b/src/check/index.htm.tpp deleted file mode 100644 index ee4255e..0000000 --- a/src/check/index.htm.tpp +++ /dev/null @@ -1,12 +0,0 @@ -{{# - html := import("html").new_render() -}} -{{ -h := html.main().body( - html.p().body( - "some paragraph shit" - ) -) - -pp.print(h) -}} diff --git a/src/contact/edit.htm.tpp b/src/contact/edit.htm.tpp deleted file mode 100644 index b762aac..0000000 --- a/src/contact/edit.htm.tpp +++ /dev/null @@ -1,20 +0,0 @@ -{{# - context.is_compo = true -}} - -
-
- - -
-
- - -
-
- - -
- - -
diff --git a/src/contact/view.htm.tpp b/src/contact/view.htm.tpp deleted file mode 100644 index 04fff93..0000000 --- a/src/contact/view.htm.tpp +++ /dev/null @@ -1,13 +0,0 @@ -{{# - //context.is_compo = true -}} - -
-
: Joe
-
: Blow
-
: joe@blow.com
- -
- diff --git a/src/incorrect.htm.tpp b/src/incorrect.htm.tpp deleted file mode 100644 index 0f67522..0000000 --- a/src/incorrect.htm.tpp +++ /dev/null @@ -1,11 +0,0 @@ -html := import("html").new_render() - -pp.print(html.html().body( - html.head().body( - html.title().body( - "some title" - ) - ), - html.body().body( - ) -)) diff --git a/src/index.htm.tpp b/src/index.htm.tpp deleted file mode 100644 index 2e4c875..0000000 --- a/src/index.htm.tpp +++ /dev/null @@ -1,78 +0,0 @@ -{{# - context.title = "The example.site main page" - - fmt := import("fmt") - html := import("html").new_render() -}} - -

This is the example page for the THT

-{{ - /*if !context.global.int { - context.global.int = 0 - } else { - context.global.int++ - }*/ - - if !context.global.val { - context.global.val = 1 - } else { - context.global.val += 1 - } - fmt.println("global: ", context.global) - req := context.http.request - q := req.url.query - // List checking. - list := [] - rng := int(q.range[0]) - fmt.println("range:", q.range) - if rng { - pp.print(`") - } - if q.name { - pp.print("
", q.name[0], "
") - } -}} -
- {{ pp.print(context.global.val) }} -
-
- Hello, Cock! -
-
- {{ - pp.print(req.url.path) - }} -
- - -{{ - vals := ["die", "with", "them", "as", "you", 1, "could", "do"] - pp.print(html.div({ - id: "the-uniq-shit" - }).body( - html.ul( - ).body( - func(){ - ret := [] - for i:=0 ; i - -
diff --git a/src/main.htm.tpp b/src/main.htm.tpp deleted file mode 100644 index b0febe7..0000000 --- a/src/main.htm.tpp +++ /dev/null @@ -1,41 +0,0 @@ -{{# - context.title = "The example.site main page" - - fmt := import("fmt") - html := import("html").new_render() -}} - - -

This is the example page for the THT

-{{ - pp.print( - html.h1().body("This is the example page for THT") - ) - - if !context.global.val { - context.global.val = 1 - } else { - context.global.val += 1 - } - - req - ("global: ", context.global) -}} - -{{ - req := context.http.request - q := req.url.query - // List checking. - rng := int(q.range[0]) - fmt.println("range:", q.range) - if rng { - pp.print(`") - } - if q.name { - pp.print("
", q.name[0], "
") - } -}} diff --git a/src/page.htm.tpp b/src/page.htm.tpp deleted file mode 100644 index f9fb15f..0000000 --- a/src/page.htm.tpp +++ /dev/null @@ -1,35 +0,0 @@ -{{# - context.title = "Let's celebrate and suck, SOME DICK" -}} - -{{markdown(` - -# Hello, World! - -This is the markdown example shit. - - func main() { - print("Fuck you") - } - -## Yet another level of header - -And even more text - -> Cheap is talk, show me the code. - -(c) Linus Torvalds - -`)}} - -
- Even more HTML -
- -{{markdown(` -### Third level header - -Some shit - -#### `, 135, ` -`)}} diff --git a/src/req.json.tpp b/src/req.json.tpp deleted file mode 100644 index 16bb6de..0000000 --- a/src/req.json.tpp +++ /dev/null @@ -1,8 +0,0 @@ -{ - "error": null, - "data": { - "name": "Andrey", - "surname": "Parhomenko", - "age": 22 - } -} diff --git a/src/request.json b/src/request.json deleted file mode 100644 index 3b0cd87..0000000 --- a/src/request.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name":"Andrew" -} diff --git a/src/script.js b/src/script.js deleted file mode 100644 index f0d1a35..0000000 --- a/src/script.js +++ /dev/null @@ -1,3 +0,0 @@ - -console.log("Hello, World!") - diff --git a/tool.go b/tool.go index 348bde8..e34f029 100644 --- a/tool.go +++ b/tool.go @@ -11,17 +11,30 @@ import ( "context" ) -var Tool = mtool.T("pp").Func(func(flags *mtool.Flags){ +var Tool = mtool.T("tpp").Func(func(flags *mtool.Flags){ + var ( + modDir string + ) + + flags.StringVar( + &modDir, + "mod", + ".", + "set the import directory", + ) + + filePaths := flags.Parse() + t := NewTengo(). SetPreCompile(func(ctx context.Context, s *Script){ s.SetImports(stdlib.GetModuleMap( stdlib.AllModuleNames()..., )) s.EnableFileImport(true) - s.SetImportDir(".") + s.SetImportDir(modDir) }) + pp := New(t) - filePaths := flags.Parse() for _, filePath := range filePaths { pth := filepath.FromSlash(filePath) bts, err := os.ReadFile(pth) @@ -41,4 +54,4 @@ var Tool = mtool.T("pp").Func(func(flags *mtool.Flags){ } os.Stdout.Write(out) } -}) +}).Usage("[files]")