hexo.theme inherits from Box, and also saves templates.

Get a View


Set a View

hexo.theme.setView(path, data);

Remove a View



Views have two methods: render and renderSync. These two methods are identical, but the former is asynchronous and the latter is synchronous. So for the sake of simplicity, we will only discuss render here.

var view = hexo.theme.getView('layout.swig');

view.render({foo: 1, bar: 2}).then(function(result){
// ...

You can pass options to the render method and it will try to process the template with the corresponding renderer and load the helpers. When rendering is complete, it will try to find whether a layout exists. If layout is false or if it doesn’t exist, the result will be returned directly.