velocity-user mailing list archives

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

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
document.

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:
					exit(0);
				case '\\': case '$': case '#':
					putc('\\', stdout);
				default:
					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>', sys.stdin.read())

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


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
accomplish?

Thanks!


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message