👉 Email protection for emails in Latte templates
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpstan.neon
ruleset.xml

README.md

Latte - email helper/filter

Small Latte helper/filter based on Smarty idea to protect your email address.


Build Status Code coverage Licence

Downloads this Month Downloads total Latest stable

Discussion / Help

Join the chat

Install

composer require contributte/latte-email

Versions

State Version Branch PHP
stable ~2.0.0 master >= 5.6
stable ~1.2.1 master >= 5.4 (old namespace)

Overview

Encodings

  • javascript
  • javascript_charcode
  • hex
  • drupal
  • texy

Usage

{var $mail = "my@email.net"}

{$mail|email:"javascript"}
{$mail|email:"javascript_charcode"}
{$mail|email:"hex"|noescape}
{$mail|email:"javascript":"link to my email here"}
{$mail|email:"drupal"}
{$mail|email:"texy"}

Install

Config

services:
    nette.latteFactory:
        setup:
            - addFilter('email', 'Contributte\Latte\Helpers\EmailHelper::mailto')
            # or
            - addFilter('email', ['Contributte\Latte\Helpers\EmailHelper', 'mailto'])

Presenter/Control

public function createTemplate() 
{
    $template = parent::createTemplate();
    $template->addFilter('email', ['Contributte\Latte\Helpers\EmailHelper', 'mailto']);
}

TemplateFactory


use Nette\Application\UI\Control;
use Nette\Bridges\ApplicationLatte\Template;

final class TemplateFactory extends Nette\Bridges\ApplicationLatte\TemplateFactory
{
    /**
     * @param Control $control
     * @return Template
     */
    public function createTemplate(Control $control = NULL)
    {
        $template = parent::createTemplate($control);
        $template->addFilter('email', ['Contributte\Latte\Helpers\EmailHelper', 'mailto']);
        return $template;
    }
}

Maintainers


Milan Felix Šulc

Thank you for testing, reporting and contributing.