mirror of
https://github.com/danog/liquid.git
synced 2024-11-30 10:59:04 +01:00
25 lines
597 B
Go
25 lines
597 B
Go
|
package render
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func TestBlockSyntax(t *testing.T) {
|
||
|
cfg := NewConfig()
|
||
|
cfg.AddBlock("if").Clause("else")
|
||
|
cfg.AddBlock("case").Clause("else")
|
||
|
cfg.AddBlock("unless")
|
||
|
|
||
|
require.Panics(t, func() { cfg.AddBlock("if") })
|
||
|
|
||
|
g := cfg.grammar
|
||
|
ifBlock, _ := g.findBlockDef("if")
|
||
|
elseBlock, _ := g.findBlockDef("else")
|
||
|
unlessBlock, _ := g.findBlockDef("unless")
|
||
|
require.True(t, elseBlock.CanHaveParent(ifBlock))
|
||
|
require.False(t, elseBlock.CanHaveParent(unlessBlock))
|
||
|
require.Equal(t, []string{"case", "if"}, elseBlock.ParentTags())
|
||
|
}
|