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

Implement RenderWithOptions Method for Custom Render Options #96

Closed
chasefleming opened this issue Dec 15, 2023 · 3 comments
Closed

Implement RenderWithOptions Method for Custom Render Options #96

chasefleming opened this issue Dec 15, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@chasefleming
Copy link
Owner

chasefleming commented Dec 15, 2023

Render now adds the preamble as noted in #91 , <!DOCTYPE html> by default. While this is the most common scenario, there may still be other environments where this is not desired. We should still offer an option to disable this if necessary. In order to keep Render() simple and to not break backwards compatibility we should add a new method called RenderWithOptions that takes a custom param of RenderOptions with a flag to DisablePreamble if desired. We could also use this to later allow less common preambles to be applied.

Example Usage

options := RenderOptions{DisablePreamble: true}
htmlString := myHtmlElement.RenderWithOptions(options)
@chasefleming chasefleming added the enhancement New feature or request label Dec 15, 2023
@AKARSHITJOSHI
Copy link

Do you expect RenderWithOptions to pass the DisablePreable to RenderTo

elem-go/elem.go

Line 114 in 72ae017

func (e *Element) RenderTo(builder *strings.Builder) {
and then put a check at

elem-go/elem.go

Line 118 in 72ae017

if e.Tag == "html" {
for handling preamble ?

@whisk
Copy link
Contributor

whisk commented Dec 17, 2023

Hi @chasefleming! I made a draft PR for this issue to figure out how this changes may look like. Please see #97 .
I changed RenderTo signature to incorporate the options. Though RenderTo is technically a public method, I don't see it's described in docs. Alsoelem-go is in development itself, so I felt free to change it.

@chasefleming
Copy link
Owner Author

chasefleming commented Dec 18, 2023

Thank you! I was actually wanting to make RenderTo to a private method, but I'm not sure it's possible with styles.CSS implementing the Node interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants