Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the type of the scripts property #67

Closed
mattesmohr opened this issue Mar 12, 2022 · 2 comments
Closed

Change the type of the scripts property #67

mattesmohr opened this issue Mar 12, 2022 · 2 comments
Assignees

Comments

@mattesmohr
Copy link
Member

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?

@MatsMoll
Copy link
Member

MatsMoll commented Apr 9, 2022

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

@mattesmohr
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants