Thanks, Dan. Vaga is excellent.

But, for example, I need a template to draw a bar of population.
The template takes a comma-separated list of cities.
The population is taken from the wikidata.

{{MyTemplate
| cities=London,Berlin,Paris
}}

Source of wikipage Template:MyTemplate:

... Some wiki markup ...
<phptag>
if ( isset($args[cities]) ) {
  $cities = explode( $delimiter, $args[cities] );
  $population = AskWikidata( 'Give me population of cities', $cities );
  $data = array_combine($cities, $population);
  echo new Vega( 
      $data,
      [ 'size'=>[400,200], 'scales'=>['x'=>'cities', y=>'population'] ] 
    );
}
</phptag>
... Some wiki markup ...

There are:
* functions 'explode', 'array_combine' is hooks of the extension PphTags Functions. (already done)
* function 'AskWikidata' is fictional, but can be implemented as hook of some extension
* objects 'Vega' is fictional, but can be implemented as hook of some extension
* 'if', 'isset', 'echo' and '[...] (array definition)' is functions of extension PhpTags (already done)

Suppose I'm developer of the extension Vega.
I should just take the javascript source code from Vega and register hook in the extension PhpTags.

source of Vega.php:

$wgHooks['PhpTagsRuntimeFirstInit'][] = 'VegaExtension::initializeRuntime';

class VegaExtension {
  public static function initializeRuntime() {
    \PhpTags\Runtime::setObjectsHook( 'VegaObject', array('Vega') );
  }
}

class VegaObject extends PhpTags\BaseHooks {
  public static function onObjectHook( ... ) {
    // some code
  }
}

The Class VegaObject will receive the arrays of data and parameters from the PhpTags,
and when the function 'echo' is called returns all the necessary data for drowing the bar on the wikipage.
a large part of the code (such as processing of various parameters) have to be implemented in the class PhpTags\BaseHooks.
The class VegaObject will just have to inform PhpTags that it needs 'vega.min.js' and convey to one ready parameters.
Since it is very simple, similar extensions can be done in one day.

Maybe I'm writing all this is off topic, forgive me please.
But I can not find anyone interested in this.
I guess I'm looking for not out there, or can not speak understandable.
Maybe I just doing nonsense and distract people from her work, I do not know.