寻找一个预处理器来填充静态文件

发布于 2024-09-10 23:26:52 字数 509 浏览 1 评论 0原文

我正在寻找的内容将允许我采用这样的内容:

index.html.template:

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

body.html.template:

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

text.txt:

4

并将其变成这样:

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

虽然示例是HTML,但我可能最终会使用一些东西很多奇怪的地方都是这样。我认为有很多预处理器;有适合这项任务的非常基本的吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星星的軌跡 2024-09-17 23:26:52

http://www.cheetahtemplate.org/

它基本上是嵌入在模板中的Python语句,所以你可以访问所有 python 功能。小例子:

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

将生成

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

此链接文件包含指令:
http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html#节000860000000000000000

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文