On Sun, 8 Dec 2019 13:26:07 -0500, Steven Schveighoffer wrote:
On 12/6/19 10:40 PM, selimozel wrote:
Hi There. This is my first post!
I am building a web application using Vibe-D. My source and diet templates are based on examples provided by the community.
I wonder if there is a way to write a simple function that returns an argument and call that function from a diet template. I checked calling embedded code section  but what I really want to have is to call functions from the source code directly.
Yes, you can, just import the module that contains the function you need
to call. Then call it from D-mode.
- import std.stdio;
- writeln("hello, world!");
Now, when you render your diet template, the server should print hello
world to the console.
Thank you Steve! I managed to run native D from diet templates. No issues there. Turns out what I was really looking for was HTTP requests sent to my server. I took a look at web_ajax example  and it is exactly what I need. I am new to web development so there's a bit of a learning curve.
I got another question now. Some of the examples under vibe-d are using "shared static this()" to define the main part of the program. I get a linker error when I try to build those ones using an atomic dub.sdl file. My hack for now is to just convert them back to "void main()" and move along. Would be happy to hear what experienced people think about this one.