44 "fmt"
55 "io"
66 "strings"
7- )
87
9- import (
108 "github.com/PuerkitoBio/goquery"
119)
1210
@@ -68,6 +66,7 @@ func NewBotFromReader(r io.Reader) (*Bot, error) {
6866 fn := func (i int , n * goquery.Selection ) {
6967 input := & Input {}
7068 input .NS = dialog .ID
69+ input .Title = n .AttrOr ("title" , "Fill/Choose ..." )
7170 input .ID = n .AttrOr ("id" , fmt .Sprintf ("input%d" , len (bot .Inputs )+ 1 ))
7271 input .Name = n .AttrOr ("name" , input .ID )
7372 input .Value = n .AttrOr ("value" , "" )
@@ -86,7 +85,13 @@ func NewBotFromReader(r io.Reader) (*Bot, error) {
8685 })
8786 bot .Inputs [input .ID ] = input
8887 n .SetAttr ("id" , input .ID )
88+ n .SetAttr ("title" , input .Title )
8989 }
90+ d .Find ("div" ).Children ().Each (func (i int , s * goquery.Selection ) {
91+ s .SetAttr ("if" , s .Parent ().AttrOr ("if" , "" ))
92+ s .Parent ().BeforeSelection (s .Clone ())
93+ })
94+ d .Find ("div" ).Remove ()
9095 d .Find ("input,select" ).Each (func (i int , n * goquery.Selection ) {
9196 switch strings .ToLower (goquery .NodeName (n )) {
9297 case "input" :
@@ -96,11 +101,6 @@ func NewBotFromReader(r io.Reader) (*Bot, error) {
96101 fn (i , n )
97102 }
98103 })
99- d .Find ("div" ).Children ().Each (func (i int , s * goquery.Selection ) {
100- s .SetAttr ("if" , s .Parent ().AttrOr ("if" , "" ))
101- s .Parent ().AfterSelection (s .Clone ())
102- s .Remove ()
103- })
104104 bot .Dialogs [dialog .ID ] = dialog
105105 d .SetAttr ("id" , dialog .ID )
106106 })
0 commit comments