code: public function getDotJsInsertForValue(array $additionalVarNameParts = [], $type = 'string', $default = null, $encodeHtml = null) {
          $jsonStringify = false;
          switch ($type) {
              case 'json_encode':
                  $jsonStringify = true;
                  $type = 'json';
                  break;
              case 'array_encode':
                  $jsonStringify = true;
                  $type = 'array';
                  break;
          }
          if ($encodeHtml === null) {
              $encodeHtml = !in_array($type, ['json', 'array'], true);
          }
          $encoding = $encodeHtml ? '!' : '=';
          if ($jsonStringify) {
              return "{{{$encoding} JSON.stringify(" . $this->getFailsafeValueForDotJs($additionalVarNameParts, $type, $default) . ') }}';
          } else {
              return "{{{$encoding} " . $this->getFailsafeValueForDotJs($additionalVarNameParts, $type, $default) . ' }}';
          }
      }
docs: Get failsafe value insert for doT.js
  Normal insert looks like:
  {{! it.viewer_name || '' }} or {{= it.viewer_name || '' }} but more complicated to provide failsafe insert
  @param array $additionalVarNameParts - additional parts of var name
  @param string $type - @see $this->getFailsafeValueForDotJs();
  Special types: 'json_encode', 'array_encode' - both apply JSON.stringify() to
  inserted value of type 'json' or 'array' respectively
  @param string|null $default - default value for cases when value is not provided or null.
  Don't forget to wrap strings into quotes:
  - "''" - inserts empty string (used instead of null),
  - "[]" inserts array
  @param bool|null $encodeHtml
  - true: encode value to allow it to be inserten into HTML arguments;
  - false: insert as is
  - null: uatodetect depending on $type
  @return string
  @throws \PeskyCMF\Scaffold\ValueViewerConfigException