Posted Sun, 08 Dec 2019 22:17:08 GMT in reply to
Steven Schveighoffer
Reply
On Sun, 8 Dec 2019 13:26:07 -0500, Steven Schveighoffer wrote:
Yes, you can, just import the module that contains the function you need
to call. Then call it from D-mode.
I decided to test this application. And created a new module hayvan.kedi (Which means animal.cat)
module havyan.kedi;
string isim()
{
return "Minnoş";
}
index.dt is like that
- import hayvan.kedi : isim;
- string başlık = "Gömülü D kodu örneği";
doctype html
head
title= başlık.toUpper
body
h1 #{ başlık }
- foreach (i; 1..4)
p Bu paragrafın numarası #{i}
- int enBüyük (int ilk, int ikinci)
- if (ilk > ikinci) return ilk; else return ikinci;
p 5 ve 12 sayıları arasında en büyük olan #{ enBüyük(5, 12) } 'dir.
p Aramızda bir kedi mi dolaşıyor? #{ isim() }
Even though I've imported the function which returns the name of the cat declared in the module file, still compiler complains.
index.dt(2,9): Error: module havyan.kedi from file source/hayvan/kedi.d must be imported with 'import havyan.kedi;'
/home/erdem/.dub/packages/diet-ng-1.6.0/diet-ng/source/diet/html.d(116,7): Error: template instance vibe.http.server.staticTemplate!"index.dt".staticTemplate.__lambda1.exec!(StreamOutputRange!(InterfaceProxy!(OutputStream), 1024LU)) error instantiating
/home/erdem/.dub/packages/vibe-d-0.8.6/vibe-d/http/vibe/http/server.d(345,66): instantiated from here: compileHTMLDietFileString!(StreamOutputRange!(InterfaceProxy!(OutputStream), 1024LU))
/home/erdem/.dub/packages/vibe-d-0.8.6/vibe-d/http/vibe/http/server.d(270,6): instantiated from here: render!("index.dt", req)
source/app.d(6,27): instantiated from here: staticTemplate!"index.dt"