rovf has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, does anybody know a CPAN module which could help me solving the following problem? I tried to search CPAN, but the closest I could found was Template, and I don't see how it can help for my application:
Assume I have a piece of code looking like this (just an example - I'm really flexible with regards to the syntax of the HERE document below):
I would like to "process" the code so that it evaluates the embedded expressions, resulting in a stringsub foo { $_[0]+$_[1] } my $template=<<END; This is some line. This is a line with some expression: # $foo(3,5) # # foreach my $s qw(this that) { # This is # $s # line # } # This is the end END
As I said, I do not have to stick to the syntax outline above. Whether the Perl expressions are delimited by '#' or by some other means, I don't care. It is not even necessary that the embedded expressions are full-blown Perl code; even some pseudocode would be OK, as long as it is powerful enough so that I can access my Perl variables, and that I can do looping construct and 'if' statements.This is some line. This is a line with some expression: 8 This is this line This is that line This is the end
In practice, the surrounding text code will be XHTML, but I would like to be able to use the same concept with other text file formats, such as JSON or RTF.
Hence, I look for something similar to what Java and Ruby programmers find in JSP and RubyOnRails, but with the twist that it should not be restricted to HTML output (the program is not running in the context of a web application; it is a stand-alone application, which just creates these text files).
BTW, for PHP, there exists a solution which comes pretty close to what I'm looking for: It's called Smarty.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looking for a "Template Engine"
by Corion (Patriarch) on Jul 22, 2008 at 11:00 UTC | |
|
Re: Looking for a "Template Engine"
by pjotrik (Friar) on Jul 22, 2008 at 11:11 UTC | |
|
Re: Looking for a "Template Engine"
by moritz (Cardinal) on Jul 22, 2008 at 10:48 UTC | |
by rovf (Priest) on Jul 22, 2008 at 11:38 UTC | |
by AltBlue (Chaplain) on Jul 22, 2008 at 17:16 UTC | |
by rovf (Priest) on Jul 23, 2008 at 08:30 UTC | |
by moritz (Cardinal) on Jul 22, 2008 at 11:54 UTC | |
|
Re: Looking for a "Template Engine"
by perrin (Chancellor) on Jul 22, 2008 at 11:50 UTC | |
by rovf (Priest) on Jul 22, 2008 at 12:03 UTC | |
by olus (Curate) on Jul 22, 2008 at 12:23 UTC | |
by rovf (Priest) on Jul 22, 2008 at 13:00 UTC | |
by karavelov (Monk) on Jul 22, 2008 at 15:27 UTC | |
|