In the [Yii 2.0 guide](http://www.yiiframework.com/doc-2.0/guide-tutorial-template-engines.html) it says you can register Javascript code in a twig template like this:

```
{registerJs key='show' position='POS_LOAD'}
    $("span.show").replaceWith('<div class="show">');
{/registerJs}

```

Tried this but it will simply output the whole snippet `{registerJs ...` as text on the page without adding it to the page's Javascript Code.

Similar commands like `registerJsFile` or `registerCss` aren't working either.

Am I missing something? Thanks!

**EDIT:**

As Mihai P. noted below, `{registerJs}` is syntax for Smarty templates. So, the question is: is there a similar way to register inline JS in Twig templates? The documentation only mentions registering assets.