composer require styleflasher/obfuscation-bundle
// config/bundles.php
return [
// ...
Styleflasher\ObfuscatorBundle\StyleflasherObfuscatorBundle::class => ['all' => true],
];
<script>
function rot13(str) {
var input = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var output = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
var index = x => input.indexOf(x);
var translate = x => index(x) > -1 ? output[index(x)] : x;
return str.split('').map(translate).join('');
}
document.getElementsByClassName("email-obfuscation").item(0).innerHTML = rot13(document.getElementsByClassName("email-obfuscation").item(0).innerHTML);
</script>
This will call obfuscateEmail
on following types:
ezrichtext_field
ezemail_field
// ezplatform.yaml
ezplatform:
system:
default:
field_templates:
- { template: '@StyleflasherObfuscator/fields/content_fields.html.twig', priority: 10 }
Now you can use it anywhere in your twig like
{{ 'test@test.test' | obfuscateEmail }}