Template Language: [!output .......]

  • Thread starter Thread starter Michael Maes
  • Start date Start date
M

Michael Maes

Hello,

I want to add a date (ShortDateString) to a custom template-file (Class).
I use:

a.. [!output SAFE_NAMESPACE_NAME]
b.. [!output SAFE_CLASS_NAME]
c.. [!output SAFE_ITEM_NAME]
But I can't find anythig on a date (something like: [!output SHORTDATE_STRING])

TIA,

Michael
 
Hi Michael,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to insert a shortdate
string into the template file.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think there is no such predefined symbol for shortdate string. We have to
do it ourself by add a symbol which represents the shortdate string into
the VCWizCtl Object.
For detailed information about the VCWizCtl Object, take a look at the
IVCWizCtrlUI interface.

We can use the AddSymbol Method of VCWizCtl Object to add the new added
symbol to the symbol table, so that when we render the Template file, the
symbols will be translated into the string it represent.

VCWizCtl Object
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/
vxlrfVCWIZLibVCWizCtl.asp

Visual C++ Wizard Model
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/
vcoriVisualCWizardModel.asp

The methods of the IVCWizCtrlUI.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/
vcoriVisualCWizardModel.asp

Here is some links about customized the Template.

Visual Studio Code Templates - Modifying Your Default Templates
http://dotnetjunkies.com/WebLog/bsblog/archive/2004/01/12/5519.aspx

Enterprise Templates: Building an Application Construction Kit in Visual
Studio .NET 2003
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechar
t/html/vstchEnterpriseTemplatesBuildingApplicationConstructionKit.asp


e.g. we can change the template of console application.
usually the wizard for the console appliation is located in the path below.
C:\Program Files\Microsoft Visual Studio .NET
2003\Vb7\VBWizards\ConsoleApplication\

We need to change two file.
1. the js file
C:\Program Files\Microsoft Visual Studio .NET
2003\Vb7\VBWizards\ConsoleApplication\Scripts\1033\default.js
Add the code below at the beginning of the OnFinish function in the file.
var date;
var dateString;
date = new Date();
dateString = (date.getMonth() + 1) + "/";
dateString += date.getDate() + "/";
dateString += date.getYear();
wizard.AddSymbol("CURRENT_DATE", dateString);

2. The template file
C:\Program Files\Microsoft Visual Studio .NET
2003\Vb7\VBWizards\ConsoleApplication\Templates\1033\Module.vb
change the file as below.

Module [!output SAFE_ITEM_NAME]

Sub Main()
[!output CURRENT_DATE]
End Sub

End Module

After that if we create a new Console application, the module file in the
new added project will be below.
Module Module1

Sub Main()
4/15/2004
End Sub

End Module


[Note: My example is just for demo, I suggest you change according to your
request]
[And this will change the default behavor of VS.NET IDE and will easily
screw things up. So please DO make a backup before make any change to this
file.]

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thank you Peter, this is 100% what I needed
(....wizard.AddSymbol("CURRENT_DATE", dateString);).
(I already implemented it)

Kind regards,

Michael

"Peter Huang" said:
Hi Michael,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to insert a shortdate
string into the template file.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think there is no such predefined symbol for shortdate string. We have to
do it ourself by add a symbol which represents the shortdate string into
the VCWizCtl Object.
For detailed information about the VCWizCtl Object, take a look at the
IVCWizCtrlUI interface.

We can use the AddSymbol Method of VCWizCtl Object to add the new added
symbol to the symbol table, so that when we render the Template file, the
symbols will be translated into the string it represent.

VCWizCtl Object
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/
vxlrfVCWIZLibVCWizCtl.asp

Visual C++ Wizard Model
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/
vcoriVisualCWizardModel.asp

The methods of the IVCWizCtrlUI.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/
vcoriVisualCWizardModel.asp

Here is some links about customized the Template.

Visual Studio Code Templates - Modifying Your Default Templates
http://dotnetjunkies.com/WebLog/bsblog/archive/2004/01/12/5519.aspx

Enterprise Templates: Building an Application Construction Kit in Visual
Studio .NET 2003
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechar
t/html/vstchEnterpriseTemplatesBuildingApplicationConstructionKit.asp


e.g. we can change the template of console application.
usually the wizard for the console appliation is located in the path below.
C:\Program Files\Microsoft Visual Studio .NET
2003\Vb7\VBWizards\ConsoleApplication\

We need to change two file.
1. the js file
C:\Program Files\Microsoft Visual Studio .NET
2003\Vb7\VBWizards\ConsoleApplication\Scripts\1033\default.js
Add the code below at the beginning of the OnFinish function in the file.
var date;
var dateString;
date = new Date();
dateString = (date.getMonth() + 1) + "/";
dateString += date.getDate() + "/";
dateString += date.getYear();
wizard.AddSymbol("CURRENT_DATE", dateString);

2. The template file
C:\Program Files\Microsoft Visual Studio .NET
2003\Vb7\VBWizards\ConsoleApplication\Templates\1033\Module.vb
change the file as below.

Module [!output SAFE_ITEM_NAME]

Sub Main()
[!output CURRENT_DATE]
End Sub

End Module

After that if we create a new Console application, the module file in the
new added project will be below.
Module Module1

Sub Main()
4/15/2004
End Sub

End Module


[Note: My example is just for demo, I suggest you change according to your
request]
[And this will change the default behavor of VS.NET IDE and will easily
screw things up. So please DO make a backup before make any change to this
file.]

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Michael,

I am glad that my suggestion will help you.

Have a nice day!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Peter Huang said:
Hi Michael,

I am glad that my suggestion will help you.

Have a nice day!

Peter, first, thanks. This is ridiculously more difficult than it should be,
and the links you gave are extremely helpful.

One note about issues like the custom date string and so on... this is one
of the things which is VERY useful about having a scripting language in
there. A string can be created using JScript's own Date() function and then
even formatted with a great deal of precision.
 
Back
Top