【发布时间】:2017-06-13 14:27:42
【问题描述】:
我需要在 Swift Vapor 应用程序中创建一个复杂的 html 表。
问题是:Leaf 似乎不支持像 #(somevar += 1) 这样的变量计数,也不支持像 #(somevar1 + somevar2) 这样的连接字符串变量
所以我决定在应用程序中创建我的复杂表并将其传输到变量内的 html 模板。 (在php中我一直都习惯这样做)
在模板中,我将变量称为
#(table)
但事实证明,我得到的是纯 html 代码,因为叶子转义了所有变量。
但是有 #raw() 函数可以打印出普通的 html。
所以我愿意
<!DOCTYPE html>
<html lang="de">
<head><title>Server</title></head>
<body>
<..>
<form action="parameters" method="post">
// here is the thing: leaf gets a html table within the string 'table'.
// If I do it like that lead doesn't recognize #(table) as a leaf variable.
#raw( #(table) )
<button type="submit">Save</button>
</form>
</body>
</html>
只是发现#raw() 不查找变量,而只是打印出未转义的 {} 之间的内容。所以我仍然进入网站“#(table)”而不是我复杂的 html-table。
所以现在我被困住了。如何将 App 生成的 html 代码作为 html 放入模板中?
可能我做错了。如何在叶子模板中获取 html 代码?还是我必须自己发送整个页面,作为带有标题的 http 流......?
提前致谢, 汤姆
【问题讨论】:
-
编辑它试图更清楚地指出我的问题......