将一个 FTL 文件导入到另一个 FTL 文件中
我已经在 FTL 文件中创建了一个 DIV,并且该 DIV 包含表单现在说我有另一个 FTL 文件,并且我想在第二个 FTL 文件中使用第一个 FTL 的 div 这可能是
deepak.ftl
<div id="filterReportParameters" style="display:none">
<form method="POST" action="${rc.getContextPath()}/leave/generateEmpLeaveReport.json" target="_blank">
<table border="0px" class="gtsjq-master-table">
<tr>
<td>From</td>
<input type="hidden" name="empId" id="empId"/>
<td>
<input type="text" id="fromDate" name="fromDate" class="text ui-widget-content ui-corner-all" style="height:20px;width:145px;"/>
</td>
<td>Order By</td>
<td>
<select name="orderBy" id="orderBy">
<option value="0">- - - - - - - Select- - - - - - - -</option>
<option value="1">Date</option>
<option value="2">Leave Type</option>
<option value="3">Transaction Type</option>
</select>
</td>
</tr>
<tr>
<td>To</td>
<td><input type="text" id="toDate" name="toDate" class="text ui-widget-content ui-corner-all" style="height:20px;width:145px;"/>
</tr>
<tr>
<td>Leave Type</td>
<td>
<select name="leaveType" id="leaveType">
<option value="0">- - - - - - - Select- - - - - - - -</option>
<#list leaveType as type>
<option value="${type.id}">${type.leaveType.description}</option>
</#list>
</select>
</td>
</tr>
<tr>
<td>Leave Transaction</td>
<td>
<select name="transactionType" id="transactionType">
<option value="0">- - - - - - - Select- - - - - - - -</option>
<#list leaveTransactionType as leaveTransaction>
<option value="${leaveTransaction.id}">${leaveTransaction.description}</option>
</#list>
</select>
</td>
</tr>
</table>
</form>
我如何在另一个 FTL 文件中使用这个 div
I have created one DIV inside a FTL file and that DIV contain form now say i have another FTL file and i want to use first FTL's div inside second FTL file is this possible
deepak.ftl
<div id="filterReportParameters" style="display:none">
<form method="POST" action="${rc.getContextPath()}/leave/generateEmpLeaveReport.json" target="_blank">
<table border="0px" class="gtsjq-master-table">
<tr>
<td>From</td>
<input type="hidden" name="empId" id="empId"/>
<td>
<input type="text" id="fromDate" name="fromDate" class="text ui-widget-content ui-corner-all" style="height:20px;width:145px;"/>
</td>
<td>Order By</td>
<td>
<select name="orderBy" id="orderBy">
<option value="0">- - - - - - - Select- - - - - - - -</option>
<option value="1">Date</option>
<option value="2">Leave Type</option>
<option value="3">Transaction Type</option>
</select>
</td>
</tr>
<tr>
<td>To</td>
<td><input type="text" id="toDate" name="toDate" class="text ui-widget-content ui-corner-all" style="height:20px;width:145px;"/>
</tr>
<tr>
<td>Leave Type</td>
<td>
<select name="leaveType" id="leaveType">
<option value="0">- - - - - - - Select- - - - - - - -</option>
<#list leaveType as type>
<option value="${type.id}">${type.leaveType.description}</option>
</#list>
</select>
</td>
</tr>
<tr>
<td>Leave Transaction</td>
<td>
<select name="transactionType" id="transactionType">
<option value="0">- - - - - - - Select- - - - - - - -</option>
<#list leaveTransactionType as leaveTransaction>
<option value="${leaveTransaction.id}">${leaveTransaction.description}</option>
</#list>
</select>
</td>
</tr>
</table>
</form>
How do i use this div in another FTL file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想将一个 freemarker 模板中的 div 包含在另一个 freemarker 模板中,您可以通过 使用来提取通用 div一个宏。例如,
然后在两个 freemarker 模板中,您可以导入 Macros.ftl 并通过以下方式调用宏:
宏是 FreeMarker 中的一个很棒的功能,也可以参数化 - 它们确实可以减少关于模板中的代码重复。
If you just want to include the div from one freemarker template in another freemarker template you can extract the common div out by using a macro. For example,
Then in both your freemarker templates, you can import
macros.ftl
and invoke the macro via something like:Macros are a great feature in FreeMarker and can be parameterized as well - they can really cut down on code duplication in your templates.
听起来您正在寻找
<#include>
指令 - Freemarker 将处理包含的文件,就好像它是包含文件的一部分一样。如果两个 FTL 文件位于同一目录中,
<#include "deepak.ftl">
将起作用。如果不是,您可以使用相对路径。It sounds like you're looking for the
<#include>
directive - the included file will be processed by Freemarker as though it was part of the including file.<#include "deepak.ftl">
will work if both the FTL files are in the same directory. You may use relative paths if they're not.