Hexo: Can I use mustache as template?

Created on 12 Aug 2017  ·  9Comments  ·  Source: hexojs/hexo

As title described, I want to make a hexo theme with mustache.
If so, what should I do?

question

Most helpful comment

I have written it.
Thank you for your encouragement, it is not as difficult as I imagined. I have published it to npm, and pull request to site, please deal with it.

All 9 comments

@snovey
You should make plugin that you want , becase this plugin not exist.

Hexo usually uses the hexo-renderer-ejs.

I recommend you to refer to hexo-renderer-jade and hexo-renderer-swig.

hexo-renderer-jade

https://github.com/hexojs/hexo-renderer-jade/blob/master/index.js

hexo-renderer-swig

https://github.com/hexojs/hexo-renderer-swig/blob/master/index.js

Hexo | Rendering

https://hexo.io/api/rendering.html

First of all, thank you for your answer.
My level may not be able to make this plugin, but if the situation allows, I will try.
Now, I want to know how do I replace the default rendering engine, is the code written in the themes/scripts folder under it? Will the default rendering engine be repeated for rendering?

@snovey

is the code written in the themes/scripts folder under it? Will the default rendering engine be repeated for rendering?

Yes , First we can verify here. Please try writing code. The Hexo rendering engine seems to be added rather than a change.

Sorry , I don't almost understand about renderer-plugin. But already existing renderer-plugin seems add renderable files. For example , hexo-renderer-ejs can render .ejs files.
https://github.com/hexojs/hexo-renderer-ejs/blob/master/index.js#L7

If you will make hexo-renderer-mustache , you should add function that will render .mustache files. Perhaps hexo-renderer-ejs also uses json to render ejs files so you can render them even with mustache in the same way.
https://github.com/hexojs/hexo-renderer-ejs/blob/master/lib/renderer.js#L7

Please do your best : )

@tea3
Thanks for your encouragement.
I will try to do it in my spare time.
If there are any questions I will ask questions again. So I do not want to close this issue until I succeeded or failed.

@snovey
I see . I wating for your results. I want you to make a repository (e.g. snovey/hexo-renderer-mustache repo ) when it is completed to a certain extent.

@tea3
I still do not understand how the hexo load the hexo-render-ejs plugin.
I try to search ejs as the keyword in the project and there is no result:
https://github.com/hexojs/hexo/search?utf8=%E2%9C%93&q=ejs&type=
And I found some description at hexo docs:

If your code is complicated or if you want to publish it to the NPM registry, we recommend using a plugin. First, create a folder in the node_modules folder. The name of this folder must begin with hexo- or Hexo will ignore it.

Does hexo load the plugins by determining the folder name prefix?

@snovey
Sorry , Please see hexo-renderer-ejs.
https://github.com/hexojs/hexo-renderer-ejs

Does hexo load the plugins by determining the folder name prefix?

It may be such a mechanism. Or it may be a formal rule.

I have written it.
Thank you for your encouragement, it is not as difficult as I imagined. I have published it to npm, and pull request to site, please deal with it.

Thanks for the contribution. Just add the reference here https://github.com/hexojs/site/pull/544 .

Was this page helpful?
0 / 5 - 0 ratings