RejectedSoftware Forums

Sign up

Diet - compileDietFile question

Hello,

I am trying to use the compileDietFileCompat! functions. My goal is to
embed personalized dynamic navigation menus for different kinds of users
in my website and also add code for persona login etc.(since i couldn't
find if there is another way to pass variables with include at diet
files and after checking the various vibe.d examples like userman and
user - auth it seemed like compileDietFile and mixins is the way to go.)

I get this error:

diet.d(192): Error: file "personaMixin.dt" cannot be found or not in a
path specified with -J
diet.d(166): Error: template instance
vibe.templ.diet.readFileRec!("persona
Mixin.dt", ) error instantiating
diet.d(96): instantiated from here: dietParser!("personaMixin.dt")
diet.d(80): instantiated from here:
compileDietFileCompatV!("persona
Mixin.dt", string, "authUserEmail",
string, "pathprefix")
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("persona
Mixin.dt", string, "authUserEmail",
string, "pathprefix")
diet.d(96): Error: template instance
vibe.templ.diet.dietParser!("persona
Mixin.dt") error instantiating
diet.d(80): instantiated from here:
compileDietFileCompatV!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
diet.d(80): Error: template instance
vibe.templ.diet.compileDietFileCompatV!("personaMixin.dt", string,
"authUserEmail", string, "path
prefix") error instantiating
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
source/webstuff.d(199): Error: template instance
vibe.templ.diet.compileDietFileCompat!("personaMixin.dt", string,
"authUserEmail", string, "path
prefix") error instantiating

I have :
protected void showLogin(HTTPServerRequest req, HTTPServerResponse res)

{
	.......

	string personaMixin = generatePersonaMixin(req);


	res.renderCompat!("login.dt",
		HTTPServerRequest, "req",
		
		string, "personaMixin")(req, personaMixin);
}

string generatePersonaMixin(HTTPServerRequest req, string path_prefix = /)

 {

    auto dst = new MemoryOutputStream;
    string authUserEmail;
    if( req.session ) authUserEmail = req.session["email"];
    compileDietFileCompat!("persona_Mixin.dt",
            string, "authUserEmail",
            string, "path_prefix")(dst,Variant(authUserEmail), 

Variant(path_prefix) );

return cast(string)dst.data();

}

and in login.dt i have :
!= personaMixin
...........

I thought that the problem was that the compileDietFile function is not
inside the render function but i tweaked the code at User - auth example
in a similar way and it works.
Any help would be appreciated!

Re: Diet - compileDietFile question

On 21/01/14 17:27 , YiannisOSC wrote:

Hello,

I am trying to use the compileDietFileCompat! functions. My goal is to
embed personalized dynamic navigation menus for different kinds of users
in my website and also add code for persona login etc.(since i couldn't
find if there is another way to pass variables with include at diet
files and after checking the various vibe.d examples like userman and
user - auth it seemed like compileDietFile and mixins is the way to go.)

I get this error:

diet.d(192): Error: file "personaMixin.dt" cannot be found or not in a
path specified with -J
diet.d(166): Error: template instance
vibe.templ.diet.readFileRec!("persona
Mixin.dt", ) error instantiating
diet.d(96): instantiated from here: dietParser!("personaMixin.dt")
diet.d(80): instantiated from here:
compileDietFileCompatV!("persona
Mixin.dt", string, "authUserEmail",
string, "pathprefix")
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("persona
Mixin.dt", string, "authUserEmail",
string, "pathprefix")
diet.d(96): Error: template instance
vibe.templ.diet.dietParser!("persona
Mixin.dt") error instantiating
diet.d(80): instantiated from here:
compileDietFileCompatV!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
diet.d(80): Error: template instance
vibe.templ.diet.compileDietFileCompatV!("personaMixin.dt", string,
"authUserEmail", string, "path
prefix") error instantiating
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
source/webstuff.d(199): Error: template instance
vibe.templ.diet.compileDietFileCompat!("personaMixin.dt", string,
"authUserEmail", string, "path
prefix") error instantiating

I have :
protected void showLogin(HTTPServerRequest req, HTTPServerResponse res)

 {
     .......

     string personaMixin = generatePersonaMixin(req);


     res.renderCompat!("login.dt",
         HTTPServerRequest, "req",

         string, "personaMixin")(req, personaMixin);
 }

string generatePersonaMixin(HTTPServerRequest req, string path_prefix = /)

 {

     auto dst = new MemoryOutputStream;
     string authUserEmail;
     if( req.session ) authUserEmail = req.session["email"];
     compileDietFileCompat!("persona_Mixin.dt",
             string, "authUserEmail",
             string, "path_prefix")(dst,Variant(authUserEmail),

Variant(path_prefix) );

 return cast(string)dst.data();

}

and in login.dt i have :
!= personaMixin
...........

I thought that the problem was that the compileDietFile function is not
inside the render function but i tweaked the code at User - auth example
in a similar way and it works.
Any help would be appreciated!

Ok there was something wrong with the .dt file itself. While extension
and path were ok was not recognized as diet file. Maybe it had to do
with my editor or something else happened by pasting or copying
elements. I replaced it and it works.

Re: Diet - compileDietFile question

Am 22.01.2014 15:29, schrieb YiannisOSC:

On 21/01/14 17:27 , YiannisOSC wrote:

Hello,

I am trying to use the compileDietFileCompat! functions. My goal is to
embed personalized dynamic navigation menus for different kinds of users
in my website and also add code for persona login etc.(since i couldn't
find if there is another way to pass variables with include at diet
files and after checking the various vibe.d examples like userman and
user - auth it seemed like compileDietFile and mixins is the way to go.)

I get this error:

diet.d(192): Error: file "personaMixin.dt" cannot be found or not in a
path specified with -J
diet.d(166): Error: template instance
vibe.templ.diet.readFileRec!("persona
Mixin.dt", ) error instantiating
diet.d(96): instantiated from here:
dietParser!("personaMixin.dt")
diet.d(80): instantiated from here:
compileDietFileCompatV!("persona
Mixin.dt", string, "authUserEmail",
string, "pathprefix")
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("persona
Mixin.dt", string, "authUserEmail",
string, "pathprefix")
diet.d(96): Error: template instance
vibe.templ.diet.dietParser!("persona
Mixin.dt") error instantiating
diet.d(80): instantiated from here:
compileDietFileCompatV!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
diet.d(80): Error: template instance
vibe.templ.diet.compileDietFileCompatV!("personaMixin.dt", string,
"authUserEmail", string, "path
prefix") error instantiating
source/webstuff.d(199): instantiated from here:
compileDietFileCompat!("personaMixin.dt", string, "authUserEmail",
string, "path
prefix")
source/webstuff.d(199): Error: template instance
vibe.templ.diet.compileDietFileCompat!("personaMixin.dt", string,
"authUserEmail", string, "path
prefix") error instantiating

I have :
protected void showLogin(HTTPServerRequest req, HTTPServerResponse res)

 {
     .......

     string personaMixin = generatePersonaMixin(req);


     res.renderCompat!("login.dt",
         HTTPServerRequest, "req",

         string, "personaMixin")(req, personaMixin);
 }

string generatePersonaMixin(HTTPServerRequest req, string path_prefix
= /)

 {

     auto dst = new MemoryOutputStream;
     string authUserEmail;
     if( req.session ) authUserEmail = req.session["email"];
     compileDietFileCompat!("persona_Mixin.dt",
             string, "authUserEmail",
             string, "path_prefix")(dst,Variant(authUserEmail),

Variant(path_prefix) );

 return cast(string)dst.data();

}

and in login.dt i have :
!= personaMixin
...........

I thought that the problem was that the compileDietFile function is not
inside the render function but i tweaked the code at User - auth example
in a similar way and it works.
Any help would be appreciated!

Ok there was something wrong with the .dt file itself. While extension
and path were ok was not recognized as diet file. Maybe it had to do
with my editor or something else happened by pasting or copying
elements. I replaced it and it works.

BTW, maybe you are already aware of it, but you could also pass the
authUserEmail and path_prefix variables to the "login.dt" template
and then put include persona_Mixin in login.dt at the location where
you have != personaMixin now. Starting with DMD 2.064, you can also
safely use render!() and compileDietFile instead of the "compat"
versions.