feat: updated tpp.

This commit is contained in:
Andrey Parhomenko 2024-07-28 18:16:41 +05:00
parent 42b7639ce4
commit bdbce0100e
6 changed files with 12 additions and 4 deletions

View file

2
go.mod
View file

@ -7,5 +7,5 @@ require (
github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2
surdeus.su/core/cli v0.1.2
surdeus.su/core/xgo v0.8.0
surdeus.su/util/tpp v0.3.3
surdeus.su/util/tpp v0.4.0
)

2
go.sum
View file

@ -18,3 +18,5 @@ surdeus.su/util/tpp v0.3.2 h1:ebcnEcY+4tgB4a6trs4GBd2CJjrZJaPKh3i5RKQf8/U=
surdeus.su/util/tpp v0.3.2/go.mod h1:rXOVXwvdc7FxRGK/Smy03AXLQiet4N+2imFesic9Vzw=
surdeus.su/util/tpp v0.3.3 h1:GEyOlt4M1jE9q9HSPAds9X85qEc/FUpD/M90vlROgLw=
surdeus.su/util/tpp v0.3.3/go.mod h1:rXOVXwvdc7FxRGK/Smy03AXLQiet4N+2imFesic9Vzw=
surdeus.su/util/tpp v0.4.0 h1:GKmduh2AHdaTEZZptCH1yFfAcYiSTX8MvXTzIam8HpM=
surdeus.su/util/tpp v0.4.0/go.mod h1:rXOVXwvdc7FxRGK/Smy03AXLQiet4N+2imFesic9Vzw=

View file

@ -84,9 +84,16 @@ func DefaultPP(mod string) *tpp.Preprocessor {
}).SetPreCode(func(ctx context.Context) []byte {
return []byte(`
__os__ := import("os")
markdown := func(...args) {
pp.write_raw(__markdown__(args...))
return pp.write_raw(__markdown__(args...))
}
markdown_file := func(file_path){
return pp.write_raw(__markdown(__os__.read_file(file_path)))
}
__http__ := immutable({
request : __http_request__
})
@ -188,9 +195,8 @@ func (h *Handler) ServeHTTP(
w.Header().Set("Content-Type", contentType)
processedData := fileData
if shouldProcess {
processedData, err = h.pp.Process(
_, processedData, err = h.pp.Process(
ctx,
true,
filePathTpp,
fileData,
)

View file

View file