Controllers

rendering only text from controlller:

    if($this->Request->isAjax()){
           $this->renderText($this->t('Responding text to ajax'));
    }

rendering any action without layout:

  $this->renderAction('edit',null,false);

Views

you can access most of controllers properties directly without the need of a “$this→” reference

in controller:
    $this->menu = 'Main';

accessing it in tpl:
    <?= $menu ?>

You should also note that $this→params is also transfered to the view like this:

in controller:
    $this->params['id'] = 3;
    $this->params['type'] = 3;

accessing it in tpl:
    <?= $id ?>
    <?= $type ?>