Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to manage a growing set of similar-but-different ASCII files. ( It so happens that they're Apache VirtualHosts, but that's not particularly relevant. ) For each production website, the developers might want as many as four variant configs for a variety of reasons.

Would you please recommend your favorite templating system? I know of a few, M4 and Template::Toolkit come to mind. My most important feature isn't power, it's intuitive operation and elegant simplicity.

share|improve this question
1  
So I can't mention template toolkit? –  xenoterracide Dec 10 '10 at 12:52
    
Of course, if you think that's the best way to go. I just want to make sure that I'm not missing something better. –  pboin Dec 10 '10 at 13:10
add comment

2 Answers

up vote 2 down vote accepted

I'm a big fan of using make and m4. I set up Nagios configuration files with extensive use of make and m4; Nagios is full of repetitive blocks that can be simplified through the use of m4.

The nice thing about make and m4 is that they are usually part of the base install or at least the base package repository on Linux and UNIX systems; with something like Template::Toolkit you'd have to install it. Perl is also heavier than m4 and make.

You can also, if you like, set up a semi-automated m4 run by putting this at the top of your m4 file (assuming the file is file.m4 for instance):

#!/usr/bin/m4 > file.conf

If you don't want to rewrite file.conf, then remove the redirection from the command:

#!/usr/bin/m4

You'd have to make the file.m4 file executable then as well:

chmod +x file.m4
share|improve this answer
add comment

I'd go for custom solution written in perl using e.g. Template::Toolkit. That way you can keep your code elegant and simple.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.