This commit is contained in:
Max 2023-11-29 20:50:01 +08:00
parent 26b03fe8a0
commit 4015573f5b
2 changed files with 24 additions and 3 deletions

View file

@ -72,9 +72,27 @@ func testPage(t *testing.T) *Page {
<div>{{ idx }} {{ article.title }}</div>
<div>{{ article.desc }}</div>
<div>{{ article.type == "article" ? "article" : "others"}}</div>
<div s:if="article.type == 'article'">article</div>
<div s:elif="article.type == 'image'">image</div>
<div s:else>others</div>
<div class="mt-10">IF</div>
<div class="p-5">
<div s:if="article.type == 'article'">article</div>
<div s:elif="article.type == 'image'">image</div>
<div s:else>others</div>
</div>
<div class="mt-10">Nested</div>
<div
s:for="article.images"
s:for-item="image"
s:for-index="imgIndex"
class="p-5"
>
<div s:if="imgIndex == 1 || imgIndex == 2" class="p-5">
{{ imgIndex }} {{ image }}
</div>
</div>
</div>
</div>
<div class="mt-10">IF</div>
<div s:if="len(articles) > 0" :name="input.data">

View file

@ -4,6 +4,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/yaoapp/kun/utils"
)
func TestRender(t *testing.T) {
@ -29,6 +30,8 @@ func TestRender(t *testing.T) {
t.Fatalf("Render error: %v", err)
}
utils.Dump(html)
assert.NotEmpty(t, html)
assert.Contains(t, html, "hello space")
assert.Equal(t, 0, len(parser.errors))