A tag allows users to quickly and easily insert snippets into their posts.
Synopsis
hexo.extend.tag.register(name, function(args, content){ |
Two arguments will be passed into the tag function: args
and content
. args
contains the arguments passed into the tag plugin and content
is the wrapped content from the tag plugin.
Since the introduction of asynchronous rendering in Hexo 3, we are using Nunjucks for rendering. The behavior may be somewhat different from that in Swig.
Options
ends
Use end tags. This option is false
by default.
async
Enable async mode. This option is false
by default.
Examples
Without End Tags
Insert a Youtube video.
hexo.extend.tag.register('youtube', function(args){ |
With End Tags
Insert a pull quote.
hexo.extend.tag.register('pullquote', function(args, content){ |
Async Rendering
Insert a file.
var fs = require('hexo-fs'); |