ComponentPro UltimateTemplateEngine

      GetTemplateSourceDir

      Language Filter: AllSend comments on this topic to ComponentPro

      GetTemplateSourceDir function is used to retrieve directory that contains the template loading from file. In order to retrieve relative path in a Web Application, you need to provide RootTemplatePath for the UltimateTemplateEngine object or pass the root template path to this function.

      GetTemplateSourceDir()

      GetTemplateSourceDir(rootTemplatePath)

      Parameter Type Description
      rootTemplatePath string Root template path.

      The examples below demonstrates how to use it

      Assume that the Template.tpl file is loaded under C:\Inetpub\wwwroot\TemplateEngine folder:

      Template.tpl
      $GetTemplateSourceDir()$

      Output will be "C:\Inetpub\wwwroot\TemplateEngine".

      Passing C:\Inetpub\wwwroot to the function:

      Template.tpl
      $GetTemplateSourceDir("C:\Inetpub\wwwroot")$

      Output will be "/TemplateEngine"

      Or setting RootTemplatePath to C:\Inetpub\wwwroot, we will have the same result:

      Template.tpl
      $GetTemplateSourceDir()$

      Output will be "/TemplateEngine"

      using System;
      using System.Collections.Generic;
      using System.Text;
      using ComponentPro;
      
      namespace CSharp
      {
          public class Sample
          {
              [STAThread]
              static void Main()
              {
                  TemplateEngine dt = new TemplateEngine();
                  dt.LoadFromFile("Template.tpl");           
                  string output = dt.Run();
                  Console.WriteLine(output);
              }
          }
      }