2019-07-11 23:16:34 +02:00
|
|
|
package templates
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/MontFerret/ferret/pkg/drivers"
|
|
|
|
)
|
|
|
|
|
2019-08-06 01:57:02 +02:00
|
|
|
var getInnerHTMLBySelectorTemplate = fmt.Sprintf(`
|
|
|
|
(el, selector) => {
|
|
|
|
const found = el.querySelector(selector);
|
|
|
|
|
|
|
|
if (found == null) {
|
|
|
|
throw new Error('%s');
|
|
|
|
}
|
|
|
|
|
|
|
|
return found.innerHTML;
|
2019-07-11 23:16:34 +02:00
|
|
|
}
|
2019-08-06 01:57:02 +02:00
|
|
|
`, drivers.ErrNotFound,
|
|
|
|
)
|
2019-07-11 23:16:34 +02:00
|
|
|
|
2019-08-06 01:57:02 +02:00
|
|
|
func GetInnerHTMLBySelector() string {
|
|
|
|
return getInnerHTMLBySelectorTemplate
|
2019-07-11 23:16:34 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 01:57:02 +02:00
|
|
|
var getInnerHTMLBySelectorAllTemplate = fmt.Sprintf(`
|
|
|
|
(el, selector) => {
|
|
|
|
const found = el.querySelectorAll(selector);
|
|
|
|
|
|
|
|
if (found == null) {
|
|
|
|
throw new Error('%s');
|
|
|
|
}
|
|
|
|
|
|
|
|
return Array.from(found).map(i => i.innerHTML);
|
2019-07-11 23:16:34 +02:00
|
|
|
}
|
2019-08-06 01:57:02 +02:00
|
|
|
`, drivers.ErrNotFound,
|
|
|
|
)
|
2019-07-11 23:16:34 +02:00
|
|
|
|
2019-08-06 01:57:02 +02:00
|
|
|
func GetInnerHTMLBySelectorAll() string {
|
|
|
|
return getInnerHTMLBySelectorAllTemplate
|
2019-07-11 23:16:34 +02:00
|
|
|
}
|