Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ardatan
Copy link

@ardatan ardatan commented Sep 8, 2017

Some view frameworks like Angular returns the full document HTML. We can do some trick to get seperately head and body in project code, but it'd better to move this trick into this package.
This new method extracts head and body, and appends them seperately into server-sink.

@apollo-cla
Copy link

@ardatan: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@@ -1,3 +1,6 @@
const HEAD_REGEX = /<head[^>]*>((.|[\n\r])*)<\/head>/im
const BODY_REGEX = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to do this right, you must use an actual parser to extract this HTML, like the one we use in server-register.js. HTML is not a regular language (the class of languages that regular expressions are adequate for parsing), but a context-free language.


// Extract body
const body = BODY_REGEX.exec(html)[1];
this.appendToBody(body);
Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, there's nothing happening here that a user of the ServerSink couldn't already do by calling sink.appendToHead and sink.appendToBody, and that code would be much easier to understand than sink.renderDocument.

@benjamn
Copy link
Contributor

benjamn commented Sep 8, 2017

I appreciate your effort and initiative, @ardatan, but this is a good example of why we have a process for proposing changes, discussing them, and (only after consensus is established) submitting a pull request: https://github.com/meteor/meteor/blob/devel/Contributing.md#proposing-your-change

Please consider creating a new issue at https://github.com/meteor/meteor-feature-requests/issues/new if you want to keep working on this. For the time being, I'm going to close this PR, because I don't think it meets the needs of any full-document-rendering frameworks (Angular, Vue, etc.), and the implementation needs work (see my comments above about using an actual HTML parser instead of regular expressions).

@benjamn benjamn closed this Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants