diff --git a/application/source/html/generate.go b/application/source/html/generate.go index ec0da820fca644064d3f5ad6517d1448a07f278b..016b8fe7f823fd93e342d9c8830b63e1c5f796d1 100644 --- a/application/source/html/generate.go +++ b/application/source/html/generate.go @@ -161,6 +161,9 @@ func doModifications(page *types.PageData, from string) (string, error) { list := cascadia.QueryAll(node, selector) for _, n := range list { if n.Parent != nil { + + removeAttr(n, m.Name) + attr := n.Attr attr = append(attr, html.Attribute{ Key: m.Name, @@ -180,3 +183,17 @@ func doModifications(page *types.PageData, from string) (string, error) { return stringWriter.String(), nil } + +func removeAttr(n *html.Node, search string) { + i := -1 + for index, attr := range n.Attr { + if attr.Key == search { + i = index + break + } + } + if i != -1 { + n.Attr = append(n.Attr[:i], n.Attr[i+1:]...) + } + +} diff --git a/development/examples/example1/html/de/test1.html b/development/examples/example1/html/de/test1.html index 5f16bd5b3458f58433a32441d5aa7acb22e6c35f..64b1c1b341397f33ee4a86883600addc6c9080ae 100644 --- a/development/examples/example1/html/de/test1.html +++ b/development/examples/example1/html/de/test1.html @@ -31,7 +31,7 @@ <script id="translations" type="application/json" data-monster-role="translation">{"key1":"value1","key2":"value2","key3":{"one":"value3","two":"value4"}}</script> - <script id="mainscript" src="/script/main22.mjs" type="module" data-xyz="YES"></script> + <script id="mainscript" src="/script/main22.mjs" type="module" type="YES"></script> </head> <body> diff --git a/development/examples/example1/template/data.yaml b/development/examples/example1/template/data.yaml index 84b808c6f166a3e5130d4d798e628f10e29e864a..5b0608a6edac4a5f9af57410832ec6ae93b74a75 100755 --- a/development/examples/example1/template/data.yaml +++ b/development/examples/example1/template/data.yaml @@ -60,7 +60,7 @@ test1.html: html: <b><span>GURKE</span></b> attributes: - selector: '#mainscript' - name: data-xyz + name: type value: YES test2.html: export: en/test2.html