Scope of “set” in twig templates

Variables set outside block in parent templates, are not overridden with values from child templates, so code like this

{% set pageTitle = 'Homepage' %}
<html>
  <head>
    <title>{{ pageTitle }}</title>
  </head>
  <body>
    {% block body %}
    Welcome, this is {{ pageTitle }}
    {% endblock %}
  </body>
</html>
{% extends 'base.twig' %}
{% set pageTitle = 'My awesome site' %}

{% block body %}
Welcome to <u>{{ pageTitle }}</u>
{% endblock %}

will render as “Welcome to Homepage”, which is not what we want. One way to deal with it is to redefine this variable in every block in child template

{% extends 'base.twig' %}
{% block body %}
{% set pageTitle = 'My awesome site' %}
Welcome to <u>{{ pageTitle }}</u>
{% endblock %}

But this has two main problems: will not work for variable usage outside blocks (like in <title> in code above), and requires to have same reassignment in every block using this variable.

To get values defined in child templates in all blocks and outside them in parent template, we have to modify set statements in base file, to check for defined variables and fallback to default value, like this:

{% set pageTitle = pageTitle|default('Homepage') %}
...

Randomly blocked port range on Windows

Without any app or service listening on it – it may be due to hns Host Networking Service – try restarting it to see if desired ports are available

Restart-Service -Name hns

or add your range to exclusion: https://dandini.wordpress.com/2019/07/15/administered-port-exclusions-blocking-high-ports/

Powershell .bashrc equivalent

Custom functions can be defined and loaded in every new session. To check where to save custom functions run:

if (!(Test-Path -Path $PROFILE )) { 
    [void](New-Item -Type File -Path $PROFILE -Force)
}
$PROFILE

If file does not exists it will be created.

Please note that this requires execution policy for powershell scripts.