-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create core PSHTML object (PSHTML.Document) #218
Comments
Proposed implementation by @LxLeChat Class Element {
[string]$Name
[string]$id
[string]$type = ($this.GetType()).Name
[System.Collections.ArrayList]$Child = @()
Element () {}
Element ($name,$id) {
$this.Name = $name
$this.id = $id
}
AddChild ([Element]$Element) {
$this.Child.Add($Element)
}
[string]ToString () {
$childreturn = ''
foreach ($child in $this.child) {
if ( $childreturn -eq '' ) {
$childreturn = $child.ToString()
} else {
$childreturn = $childreturn +$child.ToString()
}
}
return '<{0} id={1}>{2}</{0}>' -f $this.Type, $this.id,$childreturn
}
}
class html:Element{
html($id,$name):base($id,$name) {}
}
class body:Element{
body($id,$name):base($id,$name) {}
}
class div:Element{
div($id,$name):base($id,$name) {}
}
class p:Element{
p($id,$name):base($id,$name) {}
}
class script:Element{
script($id,$name):base($id,$name) {}
}
$h = [html]::new('html','htmltag')
$b = [body]::new('body','bodytag')
$s = [script]::new('script','scripttag')
$d = [div]::new('div','divtag')
$h.AddChild($b)
$h.AddChild($s)
$b.AddChild($d)
$d.AddChild([p]::new('p','ptag0'))
$d.AddChild([p]::new('p','ptag1'))
$d.AddChild([p]::new('p','ptag2'))
$b.ToString()
$h.ToString()
$d.tostring()
|
I have create a new branch to experiment on this called I have a first working implementation in the following file: It actually works pretty well. The nested elements is a part I would like to change, because for the moment it only works with script blocks (as in v2 of the solution). we should change that to an object of type The idea, is that we can have something like this: $e = div -id 'TopheaderDiv' -Class "class1 class2" -Content {
div "plop scriptblock content in my superdiv"
}
$e
$e.GetChildren()
$e.generatehtml()
(This actually works, except for the children element in -Content.) We want to be able to see the content of the HTML Tree and also to be able to generate the html structure (parts of it or the whole) using GenerateHTML() (or to be changed) method. |
(Isolating theme from #156)
Objective
I would imagine a structure along these lines:
PSHTML.Document
Perhaps also think of adding a
content
on the object, which would contain the content of each HTML tab part. It could potentially, also contain another PSHTML.Document, for nested elements.This would be done implementing the Composite Pattern
Some sources for inspiration for the exports:
The text was updated successfully, but these errors were encountered: