2019-07-11 23:16:34 +02:00
|
|
|
package templates
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/MontFerret/ferret/pkg/drivers"
|
|
|
|
)
|
|
|
|
|
|
|
|
const setInnerHTMLTemplate = `
|
|
|
|
(element, value) => {
|
|
|
|
element.innerHTML = value;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
func SetInnerHTML() string {
|
|
|
|
return setInnerHTMLTemplate
|
|
|
|
}
|
|
|
|
|
2019-08-06 01:57:02 +02:00
|
|
|
var setInnerHTMLBySelectorTemplate = fmt.Sprintf(`
|
|
|
|
(el, selector, value) => {
|
|
|
|
const found = el.querySelector(selector);
|
|
|
|
|
|
|
|
if (found == null) {
|
|
|
|
throw new Error('%s');
|
|
|
|
}
|
|
|
|
|
|
|
|
found.innerHTML = value;
|
2019-07-11 23:16:34 +02:00
|
|
|
}
|
|
|
|
`,
|
2019-08-06 01:57:02 +02:00
|
|
|
drivers.ErrNotFound,
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetInnerHTMLBySelector() string {
|
|
|
|
return setInnerHTMLBySelectorTemplate
|
2019-07-11 23:16:34 +02:00
|
|
|
}
|