mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
6ec50c5e43
* Fixed inner text * Fixed inner html * Updated set inner html and inner text * Changed mechanism of reading and writing inner text and html * updated makefile * Added e2e tests * Updated makefile * Updated changelog * Reverted dynamic page example
41 lines
735 B
Go
41 lines
735 B
Go
package templates
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/MontFerret/ferret/pkg/drivers"
|
|
)
|
|
|
|
var getInnerTextBySelectorTemplate = fmt.Sprintf(`
|
|
(el, selector) => {
|
|
const found = el.querySelector(selector);
|
|
|
|
if (found == null) {
|
|
throw new Error("%s");
|
|
}
|
|
|
|
return found.innerText;
|
|
}
|
|
`, drivers.ErrNotFound,
|
|
)
|
|
|
|
func GetInnerTextBySelector() string {
|
|
return getInnerTextBySelectorTemplate
|
|
}
|
|
|
|
var getInnerTextBySelectorAllTemplate = fmt.Sprintf(`
|
|
(el, selector) => {
|
|
const found = el.querySelectorAll(selector);
|
|
|
|
if (found == null) {
|
|
throw new Error("%s");
|
|
}
|
|
|
|
return Array.from(found).map(i => i.innerText);
|
|
}
|
|
`, drivers.ErrNotFound,
|
|
)
|
|
|
|
func GetInnerTextBySelectorAll() string {
|
|
return getInnerTextBySelectorAllTemplate
|
|
}
|