ComponentPro UltimateTemplateEngine

      IsDefined

      Language Filter: AllSend comments on this topic to ComponentPro

      IsDefined function checks to see whether a variable is defined or not. It returns True if the variable is defined, otherwise is False.

      IsDefined(variableName)

      Parameter Type Description
      variableName string Variable's name to check.

      The code below demonstrates how to use it:

      Template.tpl
      {%int a = 10/}
      
      $IsDefined("a")$

      Output will be "True"

      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);
              }
          }
      }