Improve support for modules injecting globals
Improve support for modules injecting globals

Modules can inject globals by returning a 'globals' property. The typical use
case will be to inject functions this way, but another use case is to set
request-global properties, such as config options.

In the swagger-router and tassembly architecture configuration, functions are
statically defined at compile time. This is good for performance, as it avoids
the need to build a new viewmodel for each template expansion, which would
involve a lot of property copying, or expensive prototype / Object.create
operations.

To make module-specified functions work without revealing this
behind-the-scenes optimization, we now filter out non-function globals &
assign them to the model before the expansion.

Another small tweak makes sure that the log() function is consistently
available in both JS & spec modules.

cscott/restbase,Pchelolo/restbase,eevans/restbase,wikimedia/hyperswitch,Pchelolo/restbase,inverno/restbase,wikimedia/mediawiki-services-restbase,cscott/restbase,milimetric/restbase,eevans/restbase,wikimedia/restbase,gwicke/restbase,milimetric/restbase,wikimedia/restbase,inverno/restbase,d00rman/restbase,d00rman/restbase,gwicke/restbase,wikimedia/mediawiki-services-restbase