HTMLKit icon indicating copy to clipboard operation
HTMLKit copied to clipboard

Change the type of the scripts property

Open mattesmohr opened this issue 3 years ago • 2 comments

The AnyContent protocol has a property scripts, wich has the type AnyContent. I would like to change it to a type of String.

public protocol AnyContent {
    ...
    var scripts: AnyContent { get }

}

My idea is if its a String, it can be accumulated to the top node (mostly the Page) where it can be used on the script element:

...
    public var body: AnyContent {
            ...
            Body {
                content
            }
            Script {
                self.scripts
            }
        }
    }

Would it change your first intention @MatsMoll? Or what was the intention of using scripts in the first place? Did you use scripts to accumulated it to the top? Did it work?

mattesmohr avatar Mar 12 '22 12:03 mattesmohr

The idea was the same yes! So I wanted to have it so that if a sub component relied on a script, it would be included somewhere in the top most node. I do not remember why I had it as AnyContent, but I think it was so it could include logic like if's etc. And it worked very well actually! It was a joy to stop caring about which scripts where needed for the different components when using it🙂 Hope this answered everything

MatsMoll avatar Apr 09 '22 08:04 MatsMoll

Heya Mats, thank you. I see, it definitely helps.

mattesmohr avatar Apr 25 '22 09:04 mattesmohr