diff --git a/layout.go b/layout.go
index b761de8..08751bb 100644
--- a/layout.go
+++ b/layout.go
@@ -70,7 +70,7 @@ func ValidateLayoutVariant(variant string) error {
if len(invalidSlots) == 0 {
return nil
}
- return &layoutVariantError{
+ return &LayoutVariantError{
variant: variant,
invalidSlots: invalidSlots,
invalidPositions: invalidPositions,
@@ -200,13 +200,13 @@ func (l *Layout) Render(ctx *Context) string {
return b.String()
}
-type layoutVariantError struct {
+type LayoutVariantError struct {
variant string
invalidSlots []byte
invalidPositions []int
}
-func (e *layoutVariantError) Error() string {
+func (e *LayoutVariantError) Error() string {
if e == nil {
return ErrInvalidLayoutVariant.Error()
}
@@ -237,13 +237,13 @@ func (e *layoutVariantError) Error() string {
return b.String()
}
-func (e *layoutVariantError) Unwrap() error {
+func (e *LayoutVariantError) Unwrap() error {
return ErrInvalidLayoutVariant
}
// InvalidSlots returns a copy of the invalid slot characters that were present
// in the original variant string.
-func (e *layoutVariantError) InvalidSlots() []byte {
+func (e *LayoutVariantError) InvalidSlots() []byte {
if e == nil || len(e.invalidSlots) == 0 {
return nil
}
@@ -252,7 +252,7 @@ func (e *layoutVariantError) InvalidSlots() []byte {
// InvalidPositions returns a copy of the 1-based positions of the invalid slot
// characters in the original variant string.
-func (e *layoutVariantError) InvalidPositions() []int {
+func (e *LayoutVariantError) InvalidPositions() []int {
if e == nil || len(e.invalidPositions) == 0 {
return nil
}
diff --git a/layout_external_test.go b/layout_external_test.go
new file mode 100644
index 0000000..93c18c3
--- /dev/null
+++ b/layout_external_test.go
@@ -0,0 +1,28 @@
+package html_test
+
+import (
+ "errors"
+ "testing"
+
+ html "dappco.re/go/core/html"
+)
+
+func TestValidateLayoutVariant_ExportsPositions(t *testing.T) {
+ err := html.ValidateLayoutVariant("H1X?")
+ if err == nil {
+ t.Fatal("ValidateLayoutVariant returned nil, want error")
+ }
+
+ var variantErr *html.LayoutVariantError
+ if !errors.As(err, &variantErr) {
+ t.Fatalf("errors.As(%T) failed, want *html.LayoutVariantError", err)
+ }
+
+ if got := string(variantErr.InvalidSlots()); got != "1X?" {
+ t.Fatalf("InvalidSlots() = %q, want %q", got, "1X?")
+ }
+
+ if got := variantErr.InvalidPositions(); len(got) != 3 || got[0] != 2 || got[1] != 3 || got[2] != 4 {
+ t.Fatalf("InvalidPositions() = %v, want %v", got, []int{2, 3, 4})
+ }
+}
diff --git a/layout_test.go b/layout_test.go
index 7702686..4ba6e0c 100644
--- a/layout_test.go
+++ b/layout_test.go
@@ -188,7 +188,7 @@ func TestLayout_VariantError(t *testing.T) {
variant: "H1X?",
wantErr: true,
wantErrString: "html: invalid layout variant H1X? (invalid slots: '1' at position 2, 'X' at position 3, '?' at position 4)",
- wantRender: ``,
+ wantRender: ``,
},
}
@@ -207,7 +207,7 @@ func TestLayout_VariantError(t *testing.T) {
if got := layout.VariantError().Error(); got != tt.wantErrString {
t.Fatalf("VariantError().Error() = %q, want %q", got, tt.wantErrString)
}
- if err, ok := layout.VariantError().(*layoutVariantError); ok {
+ if err, ok := layout.VariantError().(*LayoutVariantError); ok {
switch tt.variant {
case "HXC":
if got := string(err.InvalidSlots()); got != "X" {