Question

What I'm looking for would allow me to take something like this:

index.html.template:

<html>
<body>
<# include ("body.html.template") #>
</body>
</html>

body.html.template:

Hello World! <# include("text.txt") #>

text.txt:

4

And turn it into this:

<html>
<body>
Hello World! 4
</body>
</html>

While the example is HTML, I would probably end up using something like this in a lot of weird places. I think there are a number of preprocessors out there; is there a very basic one that's suited to this task?

Was it helpful?

Solution

http://www.cheetahtemplate.org/

it is basically python statements embedded in template, so you have access to all python functionality. Small example:

#for $i in $range(10)
#set $step = $i + 1
$step.  Counting from 1 to 10.
#end for

will produce

0.  Counting from 1 to 10.
1.  Counting from 1 to 10.
...

this link documents include directive: http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html#SECTION000860000000000000000

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top