martinolmr / nette-sri
Latte macro for autocreating src integrity hash
v1.0.3
2020-02-29 20:03 UTC
Requires
- php: >=7.1.0
- latte/latte: ^2.5
- nette/application: ^3.0
- nette/di: ^3.0
This package is auto-updated.
Last update: 2024-10-29 05:34:53 UTC
README
Latte macro for generating Subresource Integrity.
Generate integrity hash.
Example:
<script
src="script.js"
integrity="sha256-sha256-8mhhK6WerRskNTu3fWZ4O8xDWv8cIr5fk8QLrDhplo4="
crossorigin="anonymous">
</script>
Requires
- PHP 7.1 or later
- Framework Nette 3
- Latte templating engine
Installation
- install package by composer
composer require martinolmr/nette-sri
- update common.neon
extensions:
sriGeneratorExtension: MartinOlmr\SriGenerator\SriGeneratorExtension
service:
sriGenerator: MartinOlmr\SriGenerator\SriGenerator(%wwwDir%, %tempDir%)
latte:
macros:
- MartinOlmr\SriGenerator\SriMacro
Use
- use makro in latte
<script n:sri="/js/main.js, sha256"></script>
- params
function (string $src, string $hashAlgorithm): string
Hash algorithms
Use constants from MartinOlmr\SriGenerator\SriGeneratorType.
Available types:
- sha256
- sha384
- sha512