【发布时间】:2010-12-15 03:17:29
【问题描述】:
使用 StringTemplate,拥有标准布局模板的正确方法是:
<head>
..
</head>
<html>
$body()$
</html>
我可以在哪里设置我的应用程序的正文模板,以便我使用的每个模板都使用这个基本布局?
谢谢。
【问题讨论】:
标签: stringtemplate
使用 StringTemplate,拥有标准布局模板的正确方法是:
<head>
..
</head>
<html>
$body()$
</html>
我可以在哪里设置我的应用程序的正文模板,以便我使用的每个模板都使用这个基本布局?
谢谢。
【问题讨论】:
标签: stringtemplate
我发现它隐藏在文档中: http://www.antlr.org/wiki/display/ST/StringTemplate+2.2+Documentation
"包含名称为的模板 通过 expr 计算。参数列表 是属性分配的列表 其中每个作业的形式为 属性=表达式。例子 $(whichFormat)()$ 查找 whichFormat 的值并将其用作 模板名称。也可以申请一个 属性的间接模板。”
所以我的主要布局模板现在看起来像这样:
<head>
<title>Sportello</title>
</head>
<html lang="en-US">
<body>
$partials/header()$
<section>$(body_template)()$</section>
$partials/footer()$
</body>
</html>
...我将子模板的名称作为属性传递给它。
【讨论】: