Closed island205 closed 8 years ago
Write gulp configuration or create tree in http://github.com/posthtml/project-stub for examples
@island205 I have taken this into account, maybe (hopefully) posthtml gets a file option soon and plugins can access the path directly from the AST(PostHTMLTree)
poshtml().process(html, { file: 'path/to/file.html' }).then(({ tree }) => console.log(tree))
[
'<!DOCTYPE html>',
'\n',
{ tag: 'html', attrs: { lang: 'en' } },
'\n',
{ tag: 'head', content: [ '\n ', [Object], '\n ', [Object], '\n' ] },
'\n',
{ tag: 'body', content: [ '\n ', [Object], '\n' ] },
file: { path: 'path/to', name: 'file.html' } // <------
options: { parser: [Function] }
]
I will close this PR for now
@michael-ciniawsky great work, look forward to this api!
this is need by my posthtml plugin posthtml-web-component
say as I have an
index.html
:if i want get the real path of
hello-world.html
in<link rel="import" href="./hello-world.html">
, i need to kown the real path ofindex.html
.How?
Working with jade, well, one
posthtml
instance handle one file, i can pass thepath
byoptions
passed to the plugin.but when come to
gulp-posthtml
, i can't.options
pass to plugin only pass once, and i don't kown the real path ofindex.html
, until in the gulp stream.so my workaround is pass the real path by
options
in the.process(tree, options)
call, pass it to thetree.options
.