GetUserCodeRegion Tokens

Posts   
 
    
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 15-Jul-2006 00:00:15   

I've been trying to do some work with TemplateStudio (v1). Unless I'm missing something obvious, I've noticed that DotNetTemplateEngine.GetUserCodeRegion() only accepts a single parameter for it's commentToken (I assume to allow for C# and VB.Net style comments). However, I am doing some work with generating ASP.Net files and it would be nice to be able to have an opening and closing comment token to allow for HTML style comments.

I think it could be reasonably added via an overloaded GetUserCodeRegion method simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-Jul-2006 10:08:45   

It accepts the name for the region and returns the region in full.

The thing is: the parser also has to find the regions beforehand. So that also has to change. You want to use the regions for custom HTML ?

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-Jul-2006 21:36:53   

It works as it is now, the only thing you have to do is to wrap the string you get from GetUserCodeRegion with <!-- and -->, preferably by placing the comment tags on separate lines. You should specify as comment to GetUserCodeRegion either // or '

When the parser is scanning the file, it will find the regions and will give them one by one to you as is to you when you call GetUserCodeRegion, though without the comments. As the surrounding text is re-generated, the previous comments are removed, and the new ones are inserted.

You could also do:

<!-- <%= DotNetTemplateEngine.GetUserCodeRegion("Foo", "//"); -->

which should do the trick IMHO. Did you try this and it didn't work?

Frans Bouma | Lead developer LLBLGen Pro
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 17-Jul-2006 16:59:08   

Otis wrote:

It works as it is now, the only thing you have to do is to wrap the string you get from GetUserCodeRegion with <!-- and -->, preferably by placing the comment tags on separate lines. You should specify as comment to GetUserCodeRegion either // or '

When the parser is scanning the file, it will find the regions and will give them one by one to you as is to you when you call GetUserCodeRegion, though without the comments. As the surrounding text is re-generated, the previous comments are removed, and the new ones are inserted.

You could also do:

<!-- <%= DotNetTemplateEngine.GetUserCodeRegion("Foo", "//"); -->

which should do the trick IMHO. Did you try this and it didn't work?

Yes, this does work and is the technique I'm currently using, however it adds more for the developer using the code region to remember since they have to add additional closing and opening comments inside the block to make it work correctly. But it's an ok workaround for now.

Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 19-Jul-2006 19:42:32   

Here's another thought, is there anyway to put default content in a user region? Stuff that shows up on first gen, but is modifiable by the user and wont be overwritten on regens? I'm probably just asking too much now wink

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 19-Jul-2006 22:32:07   

You can always emit a user code region yourself, with content simple_smile For example if the getusercoderegion returns nothing, you can emit the initial section. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 19-Jul-2006 22:41:00   

Otis wrote:

You can always emit a user code region yourself, with content simple_smile For example if the getusercoderegion returns nothing, you can emit the initial section. simple_smile

At this point I'll have modified half of the open code (not open source!) stuff you have there*! I suppose that's the point, isn't it? LOL stuck_out_tongue_winking_eye

*just kidding, I've only tweaked about 3 classes wink