Re: Re: init/cleanup/shared/

"dinesh t b" <[email protected]>
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
Keats,

This outputs:

#include as template myfile.wmt

rather than evaluate it.

I have included the original message at the bottom of this email, as it got
lost or eternally held by webmacro-user-admin. -d.

----- Original Message -----
From: "Keats Kirsch" <[email protected]>
To: <[email protected]>
Sent: Thursday, May 12, 2005 7:58 PM
Subject: Re: [WebMacro-user] Re: init/cleanup/shared/


> I'm not quite sure what you're getting at but if you want a deferred
> #include you can do this with #templet/#eval.  (#macro won't work since
> they are evaluated at build time.)
>
> For example:
>
> #templet $dynaIncl { \#include as template \$file }
> #eval $dynaIncl using { "file": "myfile.wmt" }
>
> With the newest version of #eval in CVS you can do this in one step:
>
> #eval "\#include as template \$file" using { "file": "myfile.wmt" }
>
> Note the need for backslashes to escape the # and $ chars.  Otherwise
> they will get evaluated prior to the #eval.
>
> Hope this helps.
>
> Keats
>
> dinesh t b wrote:
>
> >Trying to post it again, as it did not show up
> >
> >From: "Jason E. Stewart" <[email protected]>
> >Sent: Monday, May 09, 2005 6:15 PM
> >Subject: Re: init/cleanup/shared/
> >
> >
> >
> >
> >>"dinesh t b" <[email protected]> writes:
> >>
> >>
> >>
> >>>#macro pantotoparse($file){
> >>>
> >>>this is the stuff that goes before the real parse
> >>>
> >>>#include as template $file
> >>>
> >>>and the clean up stuff after the parse
> >>>
> >>>}
> >>>
> >>>So we can use #pantotoparse("myfoo.wm") instead and we get what we
want.
> >>>
> >>>However this does not compile as #include tries to expand immediately,
> >>>and we cannot get the necessary "delay" that we want for the include.
> >>>
> >>>
> >>We should add that we're using the 2.0b of WebMacro.
> >>
> >>We tried using #eval with a #templet - but this too did not work -
> >>the #include got executed at definition time, not at run time. Putting
> >>the #include inside a string, inside the #eval didn't work either -
> >>it never got executed - instead it just printed the string...
> >>
> >>Cheers,
> >>jas.
> >>
> >>


Trying to redesign pantoto screens, with a friend (Jason Stewart), we feel
that it would be nice to have init/cleanup capabilities of mason
(Jason has been using Mason for a while) working in a WM setting.

Anyway, here was the simple idea that we tried, to have the capability of
init and cleanup. The problem is that when ever we have an #include (as
template) we would like to include some "init" WM script and "cleanup" WM
Script.

And we assumed this could be done simply by using a directive or a macro
which would be our own parse, say #pantotoparse

#macro pantotoparse($file){

this is the stuff that goes before the real parse

#include as template $file

and the clean up stuff after the parse

}

So we can use #pantotoparse("myfoo.wm") instead and we get what we want.

However this does not compile as #include tries to expand immediately,
and we cannot get the necessary "delay" that we want for the include.

Any ideas on how this can be achieved.

-dinesh


The related email from over two years ago:

----- Original Message -----
From: <[email protected]>
To: <[email protected]>; <[email protected]>;
<[email protected]>
Sent: Sunday, December 15, 2002 11:24 AM
Subject: Re: [WebMacro-user] question: print wm file name/set path
dynamically



Eric thanks! Will try that.
Now i need to add this to the beginning of each file.

We do use 1.0+

>> 2. how to prepend or append to the parse-able text
>
>I'm not sure I understand this one.  :)

This is related to the above. If I do not want to modify
each file, but am able to conditionally trun on or off this
from the program, then I would want to add the line
automatically for the parse-able text (the file to be parsed)
-- say by extending the behaviour of #parse ?

thanks much,
dinesh

Original Message:
-----------------
From: Eric B. Ridge [email protected]
Date: Sat, 14 Dec 2002 23:49:09 -0500
To: [email protected], [email protected]
Subject: Re: [WebMacro-user] question: print wm file name/set path
dynamically


On Saturday, December 14, 2002, at 11:17  PM, t b dinesh wrote:

>
> Hello hello,
>
> We seem to have gathered a large collection of .wm files that use each
> other!
> We have a need to print the file name on screen for testing/debugging
> purposes.
> Say we want the text <img src="name.gif" alt=[this file name]> or such
> to be prepended or appended to the file that is #include-d or #parse-d.
> 1. how to get the file name; and

If you put the context in the context:
    context.put ("Context", context);

from your templates, you can do this:
     This file is:  $Context.CurrentLocation

This will give you the filename (if there is one) of the current
template, plus the line.col in the template that is currently being
evaluated.  This assumes you're using a 1.0+ version of WM.  I don't
think context.getCurrentLocation() existed prior to 1.0.

> 2. how to prepend or append to the parse-able text

I'm not sure I understand this one.  :)

eric

--------------------------------------------------------------------




-- 
This message was scanned for spam and viruses by BitDefender at www.consultplanet.com



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.