velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Duffy <>
Subject Quoting a document
Date Sun, 12 Dec 2004 03:48:27 GMT

I'm about to deploy Velocity for generating UNIX config files. To help
build the templates, I'd like to be able to run the original config files
(off which the templates will be based) though a quoting process which
generates a VTL template which will precisely recreate the original

However, my naive efforts to build such a tool have so far failed. I've
attempted a C tool as follows:

	#include <stdio.h>
	int main() {
		int inchar;
		while(1) {
			inchar = fgetc(stdin);
			switch(inchar) {
				case EOF:
				case '\\': case '$': case '#':
					putc('\\', stdout);
					putc(inchar, stdout);

and a Python script as follows:

	#!/usr/bin/env python
	import re, sys
	print re.sub(r'([$#][!{a-z])', r'\\\g<1>',

However, both of these have generated templates with backslashes which
persisted in Velocity's final output files but did not exist in the

Is there a straightforward way to do what I'm attempting? If not, might
anyone suggest a tool more appropriate than VTL to the end I'm trying to


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message