InlineScript and CSP nonce attribute

Hi,

how I can add attribute nonce to InlineScript helper?

Best regards

If you activate the IDE auto-completion in your template scripts:

<?php
/**
 * @var Laminas\View\Renderer\PhpRenderer $this
 */
?>

Then you will see the available methods like this:

<?= $this->inlineScript()
    ->setAllowArbitraryAttributes(true)
    ->prependFile($this->basePath('main.js'), 'text/javascript', ['nonce' => '123456']) ?>

With setAllowArbitraryAttributes you can allow custom attributes and on the 3. parameter of prependFile you can set an array of attributes for the script element.

I did’t find this information in the documentation: InlineScript - laminas-view - Laminas Docs

Thank you!

If you miss something in the documentation then please open an issue report in the related issue tracker. Thanks in advance! :+1: