我可以在模板内设置模板继承吗? (模板工具包)
我必须根据用户所处的状态显示不同的医疗表单。还有一个许多状态共享的默认表单。这些医疗表格都是用模板工具包编写的,并且包含在更大的模板中。状态可用作标准化形式的变量。
我需要选择特定于州的模板(如果存在),否则回退到默认值。我最好怎样做呢?
INCLUDE_PATH
已用于控制网站样式之间的切换。
I have to display different medical forms according to which state the user is in. There is also a default form that many of the states share. These medical forms are all written in Template Toolkit and they are included in larger templates. The state is available as a variable in a normalized form.
I need to select the state-specific template, if it exists, otherwise fall back to the default. How would I best go about doing this?
INCLUDE_PATH
is already being used to control switching between site styles.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西应该可以完成这项工作:
main.tt:
default.tt:
s1.tt:
t.pl:
When running
t.pl
:Something like this should do the job:
main.tt:
default.tt:
s1.tt:
t.pl:
When running
t.pl
:我刚刚在具有继承的Perl模板中回答了类似的问题
使用https://template-toolkit.org/docs/manual/Views.html,此构造支持继承。
I just answered a similar question in Perl templates with inheritance
Use https://template-toolkit.org/docs/manual/Views.html, this construct supports inheritance.