I've checked Twig and realized that it can be done in different ways. Since I'm not a Twig user it's hard to decide which way is better.
For example, creating a link. In Yii2 it's:
echo Html::a('Posts, page 2', array('post/index', 'page' => 2));
If we'll use it as a Twig function as is it will be:
{{ a('Posts, page 2', {0: 'post/index', 'page': 2}) | raw }}
Not really clear, right? How would you like to use it?
There are more things to expose:
// I think Twig has it's own, right? echo Html::encode('content with <html>'); // Model-less form echo Html::beginForm(array('post/edit', 'id' => 10), 'post', array('enctype' => 'multipart/form-data')); echo Html::dropDownList('mySelect', 1, array(0 => 'A', 1 => 'B'), array('class' => 'mySelectCSSClass')); echo Html::activeLabel($postModel, 'title', array('class' => 'postTitleLabel')); echo Html::endForm(); // URL echo Html::url(array('post/index', 'page' => 2)); // application property echo \Yii::$app->language; // title of the page echo $this->title; // view partial echo $this->render('viewName', array('x' => 'y')); // using a widget echo $this->widget('yii\widgets\Something', array('x' => 'y', 'z' => 42)); // ActiveForm $form = $this->beginWidget('yii\widgets\ActiveForm'); echo $form->field($model, 'username')->textInput(); echo $form->field($model, 'password')->checkboxAlt(); $this->endWidget(); // including assets bundle $this->registerAssetBundle('jquery');