-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Provide another filter to handle the HTML(after all rendered) #4048
Comments
Hexo use Lines 83 to 89 in 0bebf60
Lines 116 to 126 in a9bbc42
|
Or provide another filter to handle the HTML(after all rendered), |
Firstly, Lines 83 to 89 in 0bebf60
layout will trigger filter execution during precompile: Lines 116 to 126 in a9bbc42
Tag plugins will trigger filter execution because they are using hexo/lib/plugins/tag/blockquote.js Line 64 in a9bbc42
hexo/lib/plugins/tag/pullquote.js Line 14 in 087b3fa
hexo/lib/plugins/helper/render.js Lines 3 to 8 in 0b26940
|
@jiangtj What about adding a new parameter There is no way to determine if it is rendering the final HTML. |
Line 58 in f332669
This may be the starting point |
Line 59 in f332669
The related line. This However, how to make |
可能我表述的有误,我说的渲染完成指的是单个html渲染完成,当它完成后我们可以对它操作 Looking at the results below, I think adding a filter here may be a good choice. The name of the filter may be |
加过滤器好简单的,就是测试用例真不会, @SukkaW 大佬加油,我溜了 |
@jiangtj I still prefer to patch |
I didn't say to remove BTW, since head is in partial in the default theme, hexo.extend.filter.register('after_render:html', (data) => {
return data.replace('</head>','<meta value="取代内容"></head>')
}); |
The test case could be: it('_generate() - after_route_render filter', () => {
const hook = sinon.spy();
hexo.extend.filter.register('after_xxx_render', hook);
hexo.theme.setView('test.swig', '0');
hexo.extend.generator.register('test', () => ({
path: 'test',
layout: 'test'
}));
return hexo._generate().then(() => {
hook.called.should.be.true;
});
}); |
Here are some plugins that should use |
#4051 merged |
@curbengh Will be updated when Hexo 4.3.0 is ready to release. |
Check List
Please check followings before submitting a new feature request.
Feature Request
I tested adding the following filters to the initial example.
This filter will be executed many times, such as md to html or ejs to html, etc.
I noticed that there are some built-in filters in hexo, but they are expected to be executed after the template engine to html rendering. If you can provide more accurate filters, you can reduce the number of regular matches and improve performance
hexo/lib/plugins/filter/after_render/index.js
Lines 6 to 7 in a9bbc42
Here are two ideas- Provideafter_render:${input}-${output}
- Provideafter_render:generate
Others
The text was updated successfully, but these errors were encountered: