Update API for embed support

This commit is contained in:
斟酌 鵬兄 2021-09-05 23:46:36 +08:00
parent 08d10e9c88
commit 8918cdd058

21
api.js
View File

@ -16,6 +16,7 @@ var BotanJS = function()
events.EventEmitter.call( this );
this.sv = {};
this.kv = {};
this.embed = {};
};
util.inherits( BotanJS, events.EventEmitter );
@ -43,6 +44,19 @@ BotanJS.prototype.remove = function( mod )
delete this.kv[ mod ];
};
BotanJS.prototype.storeForRender = function( rainet, type, ch )
{
var _self = this;
if( ch.endsWith( "." + type ) )
{
_self[ type ] = rainet + ch;
}
else
{
_self.embed[ type ] = ch;
}
};
BotanJS.prototype.compile = function( type )
{
var _self = this;
@ -89,8 +103,9 @@ BotanJS.prototype.compile = function( type )
res.on( "data", ( x ) => ch += x );
res.on( "end", function() {
_self[ type ] = rainet + ch;
res.on( "end", function()
{
_self.storeForRender( rainet, type, ch );
Dragonfly.Debug( "Storing " + ch + " to fastcache[ " + fastCache.id + " ]" );
@ -118,7 +133,7 @@ BotanJS.prototype.compile = function( type )
Dragonfly.Debug( "FastCache: " + k );
fCache.expire( 30 );
_self[ type ] = rainet + k;
_self.storeForRender( rainet, type, k );
_self.emit( "complete" );
}
else