mirror of
https://github.com/danog/liquid.git
synced 2024-11-26 19:14:39 +01:00
Merge pull request #61 from osteele/fix-windows-paths
Fixed: include tag test cases failed on Windows
This commit is contained in:
commit
c68221dd7e
@ -26,7 +26,9 @@ const (
|
||||
ObjTokenType
|
||||
)
|
||||
|
||||
// SourceLoc contains a Token's source location.
|
||||
// SourceLoc contains a Token's source location. Pathname is in the local file
|
||||
// system; for example "dir/file.html" on Linux and macOS; "dir\file.html" on
|
||||
// Windows.
|
||||
type SourceLoc struct {
|
||||
Pathname string
|
||||
LineNo int
|
||||
|
@ -61,15 +61,16 @@ func TestIncludeTag_file_not_found_error(t *testing.T) {
|
||||
|
||||
func TestIncludeTag_cached_value_handling(t *testing.T) {
|
||||
config := render.NewConfig()
|
||||
// foo.html does not exist on testdata.
|
||||
config.Cache["testdata/foo.html"] = []byte("bar")
|
||||
// missing-file.html does not exist in the testdata directory.
|
||||
config.Cache["testdata/missing-file.html"] = []byte("include-content")
|
||||
config.Cache["testdata\\missing-file.html"] = []byte("include-content")
|
||||
loc := parser.SourceLoc{Pathname: "testdata/include_source.html", LineNo: 1}
|
||||
AddStandardTags(config)
|
||||
|
||||
root, err := config.Compile(`{% include "foo.html" %}`, loc)
|
||||
root, err := config.Compile(`{% include "missing-file.html" %}`, loc)
|
||||
require.NoError(t, err)
|
||||
buf := new(bytes.Buffer)
|
||||
err = render.Render(root, buf, includeTestBindings, config)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "bar", strings.TrimSpace(buf.String()))
|
||||
require.Equal(t, "include-content", strings.TrimSpace(buf.String()))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user