Exemplo n.º 1
0
        /// <summary>
        /// merges a template and puts the rendered stream into the writer
        /// </summary>
        /// <param name="templateName">name of template to be used in merge
        /// </param>
        /// <param name="encoding">encoding used in template
        /// </param>
        /// <param name="context"> filled context to be used in merge
        /// </param>
        /// <param name="writer"> writer to write template into
        /// </param>
        /// <returns>true if successful, false otherwise.  Errors
        /// logged to velocity log
        /// @since Velocity v1.1
        /// </returns>
        public static bool MergeTemplate(System.String templateName, System.String encoding, IContext context, TextWriter writer)
        {
            Template template = RuntimeSingleton.getTemplate(templateName, encoding)
            ;

            if (template == null)
            {
                RuntimeSingleton.error("Velocity.parseTemplate() failed loading template '" + templateName + "'");
                return(false);
            }
            else
            {
                template.Merge(context, writer);
                return(true);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns a <code>Template</code> from the Velocity
 /// resource management system.
 /// </summary>
 /// <param name="name">The file name of the desired template.
 /// </param>
 /// <param name="encoding">The character encoding to use for the template.
 /// </param>
 /// <returns>    The template.
 /// @throws ResourceNotFoundException if template not found
 /// from any available source.
 /// @throws ParseErrorException if template cannot be parsed due
 /// to syntax (or other) error.
 /// @throws Exception if an error occurs in template initialization
 /// @since Velocity v1.1
 /// </returns>
 public static Template GetTemplate(System.String name, System.String encoding)
 {
     return(RuntimeSingleton.getTemplate(name, encoding));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Returns a <code>Template</code> from the Velocity
 /// resource management system.
 /// </summary>
 /// <param name="name">The file name of the desired template.
 /// </param>
 /// <returns>    The template.
 /// @throws ResourceNotFoundException if template not found
 /// from any available source.
 /// @throws ParseErrorException if template cannot be parsed due
 /// to syntax (or other) error.
 /// @throws Exception if an error occurs in template initialization
 /// </returns>
 public static Template GetTemplate(System.String name)
 {
     return(RuntimeSingleton.getTemplate(name));
 }