-
Notifications
You must be signed in to change notification settings - Fork 8
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
Content inside raw/verbatim block is still processed by PostHTML #25
Comments
Yes, it's the expected behavior (in Parcel) for HTML assets to be processed by PostHTML. It doesn't appear to provide a way to disable this. However, it makes sense to allow further processing to be disabled in parcel-plugin-nunjucks, which could be done by using an $ cat index.txt.njk <html>
<body>
<h1>Hello, {{ name }}!</h1>
{% raw %}
<img src="{{ data.image }}" />
{% endraw %}
<a href="./foo.html">Foo</a>
</body>
</html> $ cat nunjucks.config.js module.exports = {
data: { name: 'world' },
assetType (path) {
return path.baseExt === '.txt'
? 'njk' // stop after nunjucks processing (plain text)
: false // default asset-type i.e. determined by filename
}
} $ cat dist/index.txt.njk <html>
<body>
<h1>Hello, world!</h1>
<img src="{{ data.image }}" />
<a href="./foo.html">Foo</a>
</body>
</html> Note: if you only want to protect a specific section from processing by PostHTML, you'll need to use whatever the equivalent of the raw/verbatim tag is in PostHTML, or request it (probably here). |
+ load Parcel files from src/ (Parcel on Node.js >= 8) rather than lib/ (Parcel on Node.js < 8), as per our minimum-supported node version
+ load Parcel files from src/ (Parcel on Node.js >= 8) rather than lib/ (Parcel on Node.js < 8), as per our minimum-supported node version
Allow the `assetType` option to be supplied as an object with a `raw` property (default: false). If set to true, the specified type is used as the file's extension and processing stops after the nunjucks template processing. + load Parcel files from src/ (Parcel on Node.js >= 8) rather than lib/ (Parcel on Node.js < 8), as per our minimum-supported node version
Allow the `assetType` option to be supplied as an object with a `raw` property (default: false). If set to true, the specified type is used as the file's extension and processing stops after the nunjucks template processing. + load Parcel files from src/ (Parcel on Node.js >= 8) rather than lib/ (Parcel on Node.js < 8), as per our minimum-supported node version
Hi, thanks for your response. Indeed this is more a parcel/postml issue. Apparently parcel2 will provide some ways to do so. I will try to write a plugin for this. By the way it seems that your example triggers a |
The example is not what was implemented. See the PR and the documentation for the final implementation. |
Yes I've seen that afterwards, thanks for doing this. FYI I've opened a Parcel issue for my specific case ( |
Hi,
I noticed HTML content between
raw
blocks are still processed by PostHTML. So this :will trigger a build error
{{ data.image }}: ENOENT: no such file or directory
I don't know if this issue is out of scope (as writing an html string directly inside Nunjucks tags would work), do you consider this expected behavior ?
Thank you
The text was updated successfully, but these errors were encountered: