From f413c86fdcfd1d5b3588fb9dcd45e90da04d4272 Mon Sep 17 00:00:00 2001 From: George Lemon Date: Sun, 17 Mar 2024 15:56:18 +0200 Subject: [PATCH] add placeholders Signed-off-by: George Lemon --- example/initializer.nim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/example/initializer.nim b/example/initializer.nim index 3cb2dd8..5e2a0c5 100644 --- a/example/initializer.nim +++ b/example/initializer.nim @@ -4,12 +4,14 @@ import ../src/tim # Setup Tim Engine # var - timl = newTim( + timl = + newTim( src = "templates", output = "storage", basepath = currentSourcePath(), minify = true, - indent = 2 + indent = 2, + showHtmlError = true ) # some read-only data to expose inside templates @@ -48,6 +50,16 @@ let globalData = %*{ var timThread: Thread[void] proc precompileEngine() {.thread.} = {.gcsafe.}: + # let's add some placeholders + const snippetCode2 = """ +div.alert.aler.dark.rounded-0.border-0.mb-0 > p.mb-0: "Alright, I'm the second snippet loaded by #topbar placeholder." + """ + let snippetParser = parseSnippet("mysnippet", readFile("./mysnippet.timl")) + timl.addPlaceholder("topbar", snippetParser.getAst) + + let snippetParser2 = parseSnippet("mysnippet2", snippetCode2) + timl.addPlaceholder("topbar", snippetParser2.getAst) + timl.precompile( waitThread = true, global = globalData,