Skip to content

Commit 84ed7de

Browse files
feat: Turtle.get/set_Element ( Fixes #248 )
Making ToString return the element, not the SVG
1 parent 80b20dd commit 84ed7de

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Types/Turtle/ToString.ps1

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
<#
2+
.SYNOPSIS
3+
Gets the Turtle as a string
4+
.DESCRIPTION
5+
Stringifies the Turtle.
6+
7+
This will return the turtle as an element, so it can be rendered within a web page.
8+
#>
19
param()
210

3-
return "$($this.SVG.OuterXml)"
11+
$element = $this.Element
12+
if ($element -is [xml]) {
13+
$element.OuterXml
14+
} else {
15+
"$element"
16+
}
17+
return

Types/Turtle/get_Element.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ if ($this.'.Element'.ElementName) {
4343
break
4444
}
4545
)>$(
46-
# Now include any child elements
47-
if ($this.Steps -or $this.Text) {
46+
# Now include any child elements.
47+
# First, if we have drawn anything in our turtle, include that
48+
if ($this.Steps -or $this.Text -or $this.Turtles) {
4849
$this.SVG.OuterXml
4950
}
5051
@(foreach ($childCollection in 'child','ChildNodes','Children','Content') {

0 commit comments

Comments
 (0)