mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +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
753 B
Go
41 lines
753 B
Go
package templates
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/MontFerret/ferret/pkg/drivers"
|
|
)
|
|
|
|
var getInnerHTMLBySelectorTemplate = fmt.Sprintf(`
|
|
(el, selector) => {
|
|
const found = el.querySelector(selector);
|
|
|
|
if (found == null) {
|
|
throw new Error('%s');
|
|
}
|
|
|
|
return found.innerHTML;
|
|
}
|
|
`, drivers.ErrNotFound,
|
|
)
|
|
|
|
func GetInnerHTMLBySelector() string {
|
|
return getInnerHTMLBySelectorTemplate
|
|
}
|
|
|
|
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);
|
|
}
|
|
`, drivers.ErrNotFound,
|
|
)
|
|
|
|
func GetInnerHTMLBySelectorAll() string {
|
|
return getInnerHTMLBySelectorAllTemplate
|
|
}
|