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

non-callback API #8

Closed
su9204 opened this issue Feb 11, 2014 · 3 comments
Closed

non-callback API #8

su9204 opened this issue Feb 11, 2014 · 3 comments

Comments

@su9204
Copy link

su9204 commented Feb 11, 2014

Can we have a API like this
var Minimize = require('minimize')
, minimize = new Minimize({});

var resultData = minimize.parse(content);

The reason is, in some situation, it needs to be in a callback which is expected to return a result from the parser,
For example, the string replace in place,
String.replace(Regex, callback_function(rawhtml_snippet_match) {
return minimize.parse(rawhtml_snippet_match);
});

Thanks.

@su9204
Copy link
Author

su9204 commented Feb 11, 2014

By the way, it is very nice that "this module parses the DOM as string as opposes to an object.", which I think make it possible to minify html templates.

@Swaagie
Copy link
Owner

Swaagie commented Feb 12, 2014

This is a bit tricky, the callback is required by the htmlparser2 module, that module parses the DOM async. I'm not sure if that module has a sync procedure, i'll check it. Would it be possible to turn that logic around, like parse the rawhtml_snippet_match first and replace against that string after

@Swaagie
Copy link
Owner

Swaagie commented Apr 9, 2014

As far as I can tell a fully sync method is not possible atm due to htmlparser2 using domHandler which is completely async, closing this for now. Feel free to re-open when you have an awesome idea to do this.

@Swaagie Swaagie closed this as completed Apr 9, 2014
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

No branches or pull requests

2 participants