I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Bash-TPL allows you to use the FULL power of the shell scripting language of your choice, so I think we're saying the same thing.
What problem does this solve?
As with any templating language, the problem being solved is enabling you to mix some kind of logic in with a well-formatted textual file (say an HTML file, XML file, apache config, ad-hoc blog template, etc)
Say you have ~100 line config template (maybe an apache vhost template or somesuch), do you really want to be writing 100+ printf lines ?
bash-tpl manages converting your well-formatted and easy to edit text file into printf lines, while allowing you easily inject scripting logic around the file ...
The smart indentation tracking allows you clearly integrate your shell scripting without affecting the final resulting whitespace.
Trivial example:
Say you want:
<ul>
<li>item1</li>
<li>item2</li>
</ul>
Given a template:
<ul>
% for i in "${items}"; do
%# The indentation introduced by for loop content
%# will NOT be present in the output
<li><% $i %></li>
% done
</ul>
This will generate the expected output, even though you added whitespace in order to make the for-loop content clearly visible and easier to edit.
I hope that helps a bit - thanks for looking and I'm happy to answer any other questions you might have.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
What problem does this solve? Can you give a real-world example of where it would be used?
It seems to me that if you know how to type this:
then you know enough POSIX to be able to write this:
Anything large enough to need templates for output would probably be better written in a more comprehensive scripting language.
Greetings!
Bash-TPL allows you to use the FULL power of the shell scripting language of your choice, so I think we're saying the same thing.
As with any templating language, the problem being solved is enabling you to mix some kind of logic in with a well-formatted textual file (say an HTML file, XML file, apache config, ad-hoc blog template, etc)
Say you have ~100 line config template (maybe an apache vhost template or somesuch), do you really want to be writing 100+
printf
lines ?bash-tpl manages converting your well-formatted and easy to edit text file into printf lines, while allowing you easily inject scripting logic around the file ...
The smart indentation tracking allows you clearly integrate your shell scripting without affecting the final resulting whitespace.
Trivial example:
Say you want:
Given a template:
This will generate the expected output, even though you added whitespace in order to make the for-loop content clearly visible and easier to edit.
I hope that helps a bit - thanks for looking and I'm happy to answer any other questions you might have.
-TW
edit: grammar,typos
Gotcha, the example of generating a configuration file makes perfect sense.