现在我有一个base.leaf
文件可以成功地从其他文件中导入正文。
/// base.leaf
<!DOCTYPE html>
<html>
<head>
</head>
<body>
.
.
.
<!-- Begin page content -->
<div class="body-content">
#import("content")
</div>
.
.
.
</body>
</html>
在我的report.leaf
文件中,我需要根据所选选项在此页面底部显示不同的报告模板。例如,如果Wire
选择了,我想从wire.leaf
文件中导入那部分代码,依此类推。在 GRAILS GROOVY 中,部分文件的导入是通过<g:render template="/shared/report/wire" />
. 但我似乎无法弄清楚如何在vapor/leaf
.
/// report.leaf
#extend("base")
#export("content") {
<h2>Generate Report</h2>
<section>
<ul>
<li>
<label for="report">select report</label>
<select name="report">
<option value="-1">-- Select Report --</option>
<option value="1">Purchaser Confirm</option>
<option value="2">Wire</option>
<option value="3">Withdrawal Letter</option>
</select>
</li>
<li>
<input type="submit" value="run report" />
</li>
</ul>
</section>
/// Display different report templates based on the selected option
<!-- #export("report") { #embed("section") } -->
<!-- #import("wire") -->
<!-- #embed("section") -->
<!-- #import("report-content") -->
}
这是我的wire.leaf
文件。
/// wire.leaf
<!--
/// Trying the: #export("report") { #embed("section") }
<section>
<h3>Wire info for Loan # 123456789</h3>
<div>
<ul>
<li>Name: Marlin Bank</li>
<li>CMG: 007</li>
<li>MtDt: 005689</li>
<li>CUSIP: BDTK001</li>
<li>GP: 5</li>
</ul>
</div>
<div>
<input type="submit" value="print" />
</div>
</section>
-->
/// Trying the: #import("report-content")
#export("report-content") {
<section>
<h3>Wire info for Loan # 123456789</h3>
<div>
<ul>
<li>Name: Marlin Bank</li>
<li>CMG: 007</li>
<li>MtDt: 005689</li>
<li>CUSIP: BDTK001</li>
<li>GP: 5</li>
</ul>
</div>
<div>
<input type="submit" value="print" />
</div>
</section>
}
我确实阅读了这个文档,#embed
但我仍然很困惑。任何帮助将不胜感激!