New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New conditionals: is_email and is_url #1988

Closed
chris-79 opened this Issue May 31, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@chris-79

chris-79 commented May 31, 2018

Is your feature request related to a problem? Please describe.
It's pretty annoying to always create a new regex to determine if a string is an email address or is a URL. The Macros feature doesn't offer this as a shortcut, either

Describe the solution you'd like
It'd be sUpEr AwEsOmE if the conditionals is_email and is_url would be able to do the job

Describe alternatives you've considered
Tried using Macros, to no avail

Additional context
Reference for Email regex: emailregex.com

Example usage in a template:

{{ if (registration_method | is_email) }}
  <a href="mailto:{{ registration_method }}">
    Register via Email
  </a>
{{ elseif (registration_method | is_url) }}
  <a href="{{ registration_method }}">
    Open Registration Form
  </a>
{{ /if }}

Would you be willing to sponsor this feature?
Couldn't do it from my personal budget

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 31, 2018

php please make:modifiers-helper and add these:

    public function isEmail($value)
    {
        return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
    }

    public function isUrl($value)
    {
        return filter_var($value, FILTER_VALIDATE_URL) !== false;
    }

However, they're so simple I've added them to the next release anyway.

@chris-79

This comment has been minimized.

chris-79 commented May 31, 2018

AWESOME!! Your Rock, bro!

@jasonvarga jasonvarga closed this May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment