How to get form variables data into twig templates? I have a form like:

 public function buildForm(array $form, FormStateInterface $form_state, $short_title = '') {
$title = 'xyz';
}


In my .module file, I have a theme function:

function ip_mcq_theme() {
  return [
    'take_mcq_form' =&gt; [
      'render element' =&gt; 'form',
    ],
  ];
}


How to get form variables like $short_title and $title mentioned in form build function in my take-mcq-form.twig.html file?
Put the custom variable in a key with a '#', so that the formbuilder doesn't try to render this as a form element.

buildForm():

  $form['#myvars']['var1'] = 'xyz';


In twig you can access the variable in element:

form.html.twig:

  {{ element['#myvars'].var1 }}


If you set a template in #theme of the form build 

buildForm():

  $form['#theme'] = 'take_mcq_form';


you get a second template inside of form.html.twig, where you can access the variable in form:

take_mcq_form.html.twig:

  {{ form['#myvars'].var1 }}