/// <summary> /// Compiles the specified code. /// </summary> /// <param name="fileName">Name of template.</param> /// <param name="code">c# code generated from a template.</param> /// <param name="arguments">Arguments as in name, value, name, value, name, value</param> /// <param name="templateId"> /// An id to specify the exact instance of a template. Made from joining the 'TemplateClass' with the hashcode of the filename /// and the hashcode of the supplied arguments /// </param> /// <returns>Template</returns> /// <exception cref="TemplateException">If compilation fails</exception> protected ITinyTemplate Compile(string fileName, string code, TemplateArguments arguments, string templateId) { if (string.IsNullOrEmpty(code)) { throw new ArgumentException("Code is not specified."); } TemplateCompiler compiler = new TemplateCompiler(); foreach (Type type in _includedTypes) { compiler.Add(type); } try { return(compiler.Compile(arguments, code, templateId)); } catch (CompilerException err) { throw new TemplateException(fileName, err); } }
/// <summary> /// Compiles the specified code. /// </summary> /// <param name="fileName">Name of template.</param> /// <param name="code">c# code generated from a template.</param> /// <param name="arguments">Arguments as in name, value, name, value, name, value</param> /// <param name="templateId"> /// An id to specify the exact instance of a template. Made from joining the 'TemplateClass' with the hashcode of the filename /// and the hashcode of the supplied arguments /// </param> /// <returns>Template</returns> /// <exception cref="TemplateException">If compilation fails</exception> protected ITinyTemplate Compile(string fileName, string code, TemplateArguments arguments, string templateId) { if (string.IsNullOrEmpty(code)) throw new ArgumentException("Code is not specified."); TemplateCompiler compiler = new TemplateCompiler(); foreach (Type type in _includedTypes) compiler.Add(type); try { return compiler.Compile(arguments, code, templateId); } catch(CompilerException err) { throw new TemplateException(fileName, err); } }