JnHelper.cs 810 B

12345678910111213141516171819202122232425262728
  1. using JinianNet.JNTemplate;
  2. using System;
  3. using System.IO;
  4. namespace ZR.Common
  5. {
  6. public class JnHelper
  7. {
  8. /// <summary>
  9. /// 读取Jn模板
  10. /// </summary>
  11. /// <param name="dirPath"></param>
  12. /// <param name="tplName"></param>
  13. /// <returns></returns>
  14. public static ITemplate ReadTemplate(string dirPath, string tplName)
  15. {
  16. string path = Environment.CurrentDirectory;
  17. string fullName = Path.Combine(path, "wwwroot", dirPath, tplName);
  18. if (File.Exists(fullName))
  19. {
  20. return Engine.LoadTemplate(fullName);
  21. }
  22. Console.ForegroundColor = ConsoleColor.Red;
  23. Console.WriteLine($"未找到路径{fullName}");
  24. return null;
  25. }
  26. }
  27. }