Пример #1
0
 public static void RenderTemplateToWriter(string templateFile, TextWriter writer, NVelocity.VelocityContext vc)
 {
     NVelocity.App.VelocityEngine engine = null;
     IPersonalSettings provider = PersonalSettings.Provider;
     if (provider == null) {
         Commons.Collections.ExtendedProperties props = new Commons.Collections.ExtendedProperties();
         props.SetProperty(NVelocity.Runtime.RuntimeConstants.RESOURCE_LOADER, "file");
         props.SetProperty(NVelocity.Runtime.RuntimeConstants.FILE_RESOURCE_LOADER_PATH, _defaultPath);
         props.SetProperty(NVelocity.Runtime.RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");
         engine = new NVelocity.App.VelocityEngine(props);
     }
     else
         engine = (NVelocity.App.VelocityEngine)PersonalSettings.Provider.ViewEngine;
     NVelocity.Template template = engine.GetTemplate(templateFile);
     template.Merge(vc, writer);
 }
Пример #2
0
 public static string CreateCode(string codeString,NVelocity.VelocityContext context)
 {
     StringWriter writer = new StringWriter();
     try
     {
         VelocityEngine engine= new VelocityEngine();
         engine.Init();
         if (context == null)
             context = new VelocityContext();
         engine.Evaluate(context, writer, "", codeString);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return writer.ToString();
 }
 public override bool IsSourceModified(NVelocity.Runtime.Resource.Resource resource)
 {
     return false;
 }
 public override long GetLastModified(NVelocity.Runtime.Resource.Resource resource)
 {
     return 1;
 }
Пример #5
0
 /**
  * Break directive does not actually do any rendering. 
  * 
  * This directive throws a BreakException (RuntimeException) which
  * signals foreach directive to break out of the loop. Note that this
  * directive does not verify that it is being called inside a foreach
  * loop.
  * 
  * @param context
  * @param writer
  * @param node
  * @return true if the directive rendered successfully.
  * @throws IOException
  * @throws MethodInvocationException
  * @throws ResourceNotFoundException
  * @throws ParseErrorException
  */
 public override bool Render(IInternalContextAdapter context, TextWriter writer, NVelocity.Runtime.Parser.Node.INode node)
 {
     throw new BreakException();
 }
Пример #6
0
 public void Init(NVelocity.Runtime.IRuntimeServices rs)
 {
     //throw new NotImplementedException();
 }
Пример #7
0
 public override void Init(NVelocity.Runtime.IRuntimeServices rs, IInternalContextAdapter context, INode node)
 {
     base.Init(rs, context, node);
 }