Skip to content

Commit e6af57e

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

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Turtle.types.ps1xml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4264,9 +4264,23 @@ return $this.LSystem('F+F+F+F', [Ordered]@{
42644264
<ScriptMethod>
42654265
<Name>ToString</Name>
42664266
<Script>
4267-
param()
4267+
&lt;#
4268+
.SYNOPSIS
4269+
Gets the Turtle as a string
4270+
.DESCRIPTION
4271+
Stringifies the Turtle.
4272+
4273+
This will return the turtle as an element, so it can be rendered within a web page.
4274+
#&gt;
4275+
param()
42684276

4269-
return "$($this.SVG.OuterXml)"
4277+
$element = $this.Element
4278+
if ($element -is [xml]) {
4279+
$element.OuterXml
4280+
} else {
4281+
"$element"
4282+
}
4283+
return
42704284
</Script>
42714285
</ScriptMethod>
42724286
<ScriptMethod>
@@ -4983,8 +4997,9 @@ if ($this.'.Element'.ElementName) {
49834997
break
49844998
}
49854999
)&gt;$(
4986-
# Now include any child elements
4987-
if ($this.Steps -or $this.Text) {
5000+
# Now include any child elements.
5001+
# First, if we have drawn anything in our turtle, include that
5002+
if ($this.Steps -or $this.Text -or $this.Turtles) {
49885003
$this.SVG.OuterXml
49895004
}
49905005
@(foreach ($childCollection in 'child','ChildNodes','Children','Content') {

0 commit comments

Comments
 (0)