Functions prefixed with html_
perform tasks that are useful when dealing with htmls. The helper maps directly to the Html
PHP class and its methods.
{{ html_strip() }}
Is the PHP equivalent of the following:
<?= Html::strip() ?>
Note: Methods in camelCase should be converted to snake_case.
Removes HTML from a string.
{{ html_strip('<strong>Hello world</strong>') }}
Limits HTML with specific length with a proper tag handling.
{{ html_limit('<p>Post content...</p>', 100) }}
To add a suffix when limit is applied, pass it as the third argument. Defaults to ...
.
{{ html_limit('<p>Post content...</p>', 100, '... Read more!') }}
Cleans HTML to prevent most XSS attacks.
{{ html_clean('<script>window.location = "http://google.com"</script>') }}
Obfuscates an e-mail address to prevent spam-bots from sniffing it.
{{ html_email('[email protected]') }}
For example:
<a href="mailto: {{ html_email('[email protected]')|raw }}">Email me</a>
<!-- The above will output -->
<a href="mailto: mailto:a@b.c">Email me</a>