Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

html string #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

sepiropht
Copy link

#82

Copy link
Owner

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sepiropht it helps me help you if you describe any issues you are having in a WIP PR, and which parts are still in progress, and if you need help/feedback or are just checkpointing some work. Without any context, I don't know if you want me to look at the code or just wait until it isn't marked WIP anymore, or if you are stuck and are banging your head against the wall, or...

Please communicate so everything goes smoothly :)

Overall, this is a good start, but needs a little bit of work before landing -- see inline comments below. Thanks!

src/node.rs Outdated
use bumpalo::Bump;
use std::fmt;
use std::iter;
use std::mem;
use std::u32;


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: don't add an extra newline here.

@@ -269,3 +272,33 @@ impl Listener<'_> {
}
}
}

pub fn html_string<R>(component: &R) -> String
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: this function needs documentation and an example of using it.

let cached_set = &RefCell::new(CachedSet::default());
let bump = &Bump::new();
let templates = &mut FxHashMap::default();
RenderContext {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is failing to compile because it is trying to return something that contains a borrow of something from the stack frame we are returning from?

Since RenderContext contains a borrow, but we don't want callers to have to supply any parameters that we will borrow from, I think we should make this a callback-based API:

pub(crate) fn empty<F, T>(f: F) -> T
where
    F: FnOnce(&mut RenderContext) -> T
{
    // ...
    f(&mut RenderContext { ... })
}

// and then usage would be like:

RenderContext::empty(|cx| {
    // use cx here...
})

Does that make sense?

/// return an empty rendering context
pub_unstable_internal! {
pub(crate) fn empty() -> Self {
let cached_set = &RefCell::new(CachedSet::default());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: please indent code properly. Everything within a function body should be 4 spaces indented.

@sepiropht sepiropht force-pushed the feature-html-string branch 2 times, most recently from 0677d4d to f79215b Compare July 8, 2019 21:18
@sepiropht sepiropht force-pushed the feature-html-string branch from f79215b to 301ab1c Compare July 23, 2019 09:53
@theduke
Copy link

theduke commented Aug 6, 2019

What's the status here?

@sepiropht
Copy link
Author

@theduke It is not finished yet, i'm still struggle a bit to add tests.

@fitzgen
Copy link
Owner

fitzgen commented Aug 7, 2019

i'm still struggle a bit to add tests.

What are you struggling with? Anything I can do to help smooth things out?

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

Successfully merging this pull request may close these issues.

3 participants