-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standard library #5
Comments
Signed-off-by: George Lemon <[email protected]>
Hi I have some questions about this:
To clarify further: $ cat index.nimja
<div>{{printNum1()}}<div/> #FILE: server.nim
import nimja
proc printNum1(): int = 1
## Route Handlers
proc getLandingPage(): string =
result = tmplf(getScriptDir() & "/index.nimja")
echo getLandingPage() #<div>1<div/> This approach can easily scale to all the languages Tim wishes to support although am not sure how the syntax or implementation details will work. if question2's answer is yes, then if I understand correctly Tim users are provided with some extra built-in functions that they can use within their templates just like liquidjs templating engine's I understand that the answer for both of these questions can be yes. In this case, tim will allow users to call functions/procedures in the same scope as the Thanks for reading and I look forward to getting a better understanding of this proposal |
Well, yes, the main idea around So, The current In addition to S2S compilation feature, the CLI will also provide the option to use Tim as a standalone microservice in background. So, there will be a |
Currently, exposing a function is possible by doing this import pkg/tim
# initialize tim engine
var timEngine* = newTim("templates", "storage", currentSourcePath())
# initialize the local module
# note that `proc hello` is converted into `fn hello` in Tim.
# Also, this is pretty low-level and requires working with Tim's AST structure.
tim.initModule:
block:
proc hello(x: string): string =
# args[0].value is an ast.Node type of ntLitString
result = ast.newNode(ntLitString)
result.sVal = "Hello " & args[0].value.sVal
# ... precompilation and app setup
Obviously this works for Tim when used as a Nimble package. For the CLI app
|
Thanks for clarifying, I love the direction you are taking it.
but I will just observe and learn. |
Tim should borrow some callable utilities from Nim's standard library
Tim's standard library in modules:
std/system
,std/strings
,std/arrays
,std/objects
,std/math
andstd/os
(read-only functions)The text was updated successfully, but these errors were encountered: