public ProcessTemplate ( string templateFileName, string outputFileName ) : |
||
templateFileName | string | |
outputFileName | string | |
return |
/// <summary> /// Render the model and returns the results /// </summary> /// <param name="modelPath"></param> /// <param name="modelType"></param> /// <param name="ttPath"></param> public string RenderModel(string modelPath, string modelType, string ttPath, bool preProcess) { if (!string.IsNullOrEmpty(_basePath)) { modelPath = modelPath.Replace("~", _basePath); ttPath = ttPath.Replace("~", _basePath); } if (!File.Exists(modelPath) || !File.Exists(ttPath)) { throw new Exception("Model file ('" + modelPath + "') or Template file ('" + ttPath + "') doesn't exist."); } string templateData = Properties.Resources.Header + File.ReadAllText(ttPath) + Properties.Resources.Footer.Replace("~~", Path.GetFullPath(modelPath)); File.WriteAllText(ttPath + ".tmp", templateData); DynamicTemplateHost thost = new DynamicTemplateHost(); string data = string.Empty; _errors.Clear(); var results = thost.ProcessTemplate(ttPath + ".tmp", out data); foreach (var res in results) { _errors.Add(res as CompilerError); } try { File.Delete(ttPath + ".tmp"); } catch { } return(data); }
/// <summary> /// Render the model and returns the results /// </summary> /// <param name="modelPath"></param> /// <param name="modelType"></param> /// <param name="ttPath"></param> public string RenderModel(string modelPath,string modelType, string ttPath,bool preProcess) { if (!string.IsNullOrEmpty(_basePath)) { modelPath = modelPath.Replace("~", _basePath); ttPath = ttPath.Replace("~", _basePath); } if (!File.Exists(modelPath) || !File.Exists(ttPath)) { throw new Exception("Model file ('" + modelPath + "') or Template file ('" + ttPath + "') doesn't exist."); } string templateData = Properties.Resources.Header + File.ReadAllText(ttPath) + Properties.Resources.Footer.Replace("~~", Path.GetFullPath(modelPath)); File.WriteAllText(ttPath + ".tmp", templateData); DynamicTemplateHost thost = new DynamicTemplateHost(); string data = string.Empty; _errors.Clear(); var results = thost.ProcessTemplate(ttPath + ".tmp", out data); foreach (var res in results) _errors.Add(res as CompilerError); try { File.Delete(ttPath + ".tmp"); } catch { } return data; }