2
나는 다음과 같은 구조 내 응용 프로그램에서 태그가 :확인 HTML 조각의 무효 2.3.0
@(
columns: Integer
)(header: Html)(body: Html)
<table>
@if(header != null) {
<thead>
<tr>
@header
</tr>
</thead>
}
// Body and foot here
</table>
을 그리고 나는이 같은 내 템플릿에 사용 :
@tags.Table(5) { } {
// My content here
}
이전 코드는 작동하지 않습니다. 대괄호를 비워도 <thead></thead>
이 표시됩니다. 그렇다면 header
이 비어 있지 않음을 확인하는 방법과 템플릿에 내 태그를 선언하는 방법은 무엇입니까? { }
으로 신고하는 것이 잘못 되었나요?
type mismatch;
found : Unit
required: play.twirl.api.Html
완벽! Thanks @ LimbSoup – c4k
'{HtmlFormat.empty}'에 대해'(HtmlFormat.empty)'를 변경해야합니다. –
빈 문자열을 피하기 위해 본문 내용을 다듬어야 할 수도 있습니다. 제 경우에는'@if (! header.body.trim.isEmpty)'를 사용했습니다. https://www.playframework.com/documentation/2.4.x/api/scala/index.html#play.twirl.api.Html에서 자세한 내용보기 –