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

Add from option #4

Closed
wants to merge 1 commit into from
Closed

Add from option #4

wants to merge 1 commit into from

Conversation

TrySound
Copy link

@TrySound TrySound commented Feb 8, 2016

This will let make include, imports or something other more flexible.
The same is used in postcss (node.source.input.file)

@awinogradov
Copy link
Member

@TrySound you can transfer any file to posthtml with gulp or other engines. Look at https://www.npmjs.com/package/gulp-posthtml

@TrySound
Copy link
Author

TrySound commented Feb 8, 2016

@awinogradov Yeah. I know. It's not about any wrappers. This will add file prop to any tag and will let to use relative path of current file not only some root.

@TrySound
Copy link
Author

TrySound commented Feb 8, 2016

@awinogradov It's just meta data not actions.

@awinogradov
Copy link
Member

@TrySound yes, I understand. But nobody uses posthtml-parser separately. It's API shouldn't to be here. You should transfer string to the parser. I think it's the right idea because tomorrow somebody will want to get a string by HTTP. Why not?) This is variant of getting content and it should be on the high level.

@awinogradov
Copy link
Member

@TrySound can you write example of usage for this prop?

@voischev
Copy link
Member

voischev commented Feb 8, 2016

want to get a string by HTTP

👍

@voischev
Copy link
Member

voischev commented Feb 8, 2016

and what to do with text nodes?

@TrySound
Copy link
Author

TrySound commented Feb 8, 2016

We just will pass posthtml options in parser in next release.
Flatten text nodes is your api omission. Need major release for this case and plugins rewriting.
posthtml
https://github.com/posthtml/posthtml-include/blob/master/index.js#L14
In postcss we use this everywhere when we want to get relative paths (+sourcemaps if somebody want to support them in future)
https://github.com/postcss/postcss-import/blob/master/index.js#L220-L222
https://github.com/TrySound/postcss-inline-svg/blob/master/lib/resolve.js#L3-L11

@TrySound
Copy link
Author

TrySound commented Feb 8, 2016

want to get a string by HTTP

It won't affect nothing at all. We are deciding another problem here.

@TrySound
Copy link
Author

TrySound commented Feb 8, 2016

However resolving should be in posthtml.

@awinogradov
Copy link
Member

@TrySound if you want this meta you should have target or problem? How you plan use this meta?

@TrySound
Copy link
Author

TrySound commented Feb 8, 2016

@awinogradov In include something like

if (src) {
  var resolvedId = path.resolve(node.file || options.root, src);
  content = parser(fs.readFileSync(resolvedId, options.encoding));
}

@awinogradov
Copy link
Member

Ok) Now it works fine. Write in your HTML <div src='path/to/file'></div> then catch it in plugin node.attrs.src ;)

@TrySound
Copy link
Author

TrySound commented Feb 9, 2016

What? Seriously? By hand?

@TrySound TrySound closed this Feb 9, 2016
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