This VB macro is a handy utility for use in Microsoft Visual Studio 2005 when editing Dynamic Web Templates. It til insert a remark at the begining of the template which says in which directory the template is placed, and the name of it.
It also inserts a not active <!--@DwTemplateTags-->, a tag which at the time where the template is rendered, will show you which template tags are availible, and their values.
- Copy'n'paste the code below into a file named (for instance) "DwUtils.vb"
- Save it and import it into VS2005.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Public Module DwUtils
Sub prepareTemplate()
Dim doc As Document
Dim desc As String
Dim sName As String
Dim sPath As String
Dim i As Integer
Dim temp As Array
doc = DTE.ActiveDocument
sName = doc.Name
sPath = doc.Path
temp = sPath.Split("\")
desc = ""
For i = temp.Length - 3 To temp.Length - 1
desc = desc & "/" & temp(i)
Next
sName = desc & sName
Dim textSelection As TextSelection
textSelection = DTE.ActiveDocument.Selection
textSelection.GotoLine(1)
textSelection.Insert("" & vbCrLf)
textSelection.EndOfDocument()
textSelection.Insert(vbCrLf & "")
End Sub
End Module
No comments:
Post a Comment