Tools for processing "template"?

Fabio FZero fabio.fzero-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Sat May 22 01:38:56 UTC 2010


(Sorry, I pressed the send button too soon!)

By the way, I can't understand why the data gathering part would be a
problem. If you can put it on a file, the process can always be done
two steps. If you absolutely can't, pipes are there to be used.

On Fri, May 21, 2010 at 21:30, Fabio FZero <fabio.fzero-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> There's more then one way to do it!
>
> 1. You could use PHP from the command-line. Yep, you can write PHP
> scripts as you would with Perl, Python or Ruby. Just start the script
> with...
>
> #!/usr/bin/php -q
>
> ...and write al your code between <?php and ?>. The command-line
> arguments will be in $_SERVER['argv']. From then on you can use
> explode() and implode() (or regexes) to make the substitutions.
>
> 2. Perl, of course.
>
> 3. You can use many of the classes and gems available for Ruby to deal
> with this. Everything you can use for the web (ERB seems perfect for
> your case) is available to use anywhere else. Ruby's string methods
> are *at least* as good as Perl's.
>
> About ERB:
> http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/erb/rdoc/index.html
>
> 4. That stands true for Python too, but can be little bit more
> long-winded if you want t use regular expressions. On the other hand,
> the string.Formatter is awesome
>
> http://docs.python.org/library/string.html
>
> 5. You could always use awk or successive calls to sed, but that would
> be painful and slow. Anyway, if you're a bash fan who likes write-only
> code and have time to spare, this could be for you!
>
> - FZero
>
> On Fri, May 21, 2010 at 18:13, William Park <opengeometry-FFYn/CNdgSA at public.gmane.org> wrote:
>>
>> Hi all,
>>
>> This seems to be recurring task.  What tools to you use to process
>> "template"?
>>
>> That is, you have a template file (say, a text file) with bunch of
>> placeholders, and you need to replace those placeholders with actual
>> data (say, generated by script, extracted from other files, calculated
>> by formula, etc).
>>
>> The reason why I'm asking is that getting the "actual data" to insert is
>> not that easy to do in PHP, Perl, or Python, even if I were to write
>> C-extensions to those languages.  This could be for many reasons, ie.
>> development time, maintenance/support issue, hardware/system constraint,
>> 3rd-party application quirks, etc.
>>
>> --
>> William
>>
>> --
>> The Toronto Linux Users Group.      Meetings: http://gtalug.org/
>> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
>> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
>
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list