mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-08 03:13:15 +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
35 lines
558 B
Go
35 lines
558 B
Go
package templates
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/MontFerret/ferret/pkg/drivers"
|
|
)
|
|
|
|
const setInnerTextTemplate = `
|
|
(element, value) => {
|
|
element.innerText = value;
|
|
}
|
|
`
|
|
|
|
func SetInnerText() string {
|
|
return setInnerTextTemplate
|
|
}
|
|
|
|
var setInnerTextBySelectorTemplate = fmt.Sprintf(`
|
|
(el, selector, value) => {
|
|
const found = el.querySelector(selector);
|
|
|
|
if (found == null) {
|
|
throw new Error('%s');
|
|
}
|
|
|
|
found.innerText = value;
|
|
}
|
|
`,
|
|
drivers.ErrNotFound,
|
|
)
|
|
|
|
func SetInnerTextBySelector() string {
|
|
return setInnerTextBySelectorTemplate
|
|
}
|