Difference between revisions of "Template:Mailto"

(Rework the template for better usability.)
 
Line 1: Line 1:
<noinclude>This template simplifies the addition of clickable email addresses to a page.  It takes one to three parameters, as follows:
+
<noinclude>This template simplifies the addition of clickable email addresses to a page.  It takes one or two parameters, as follows:
  
* The first parameter is the local part of the email address.  It's the only required parameter.  If no other parameters are supplied, it assumes the domain is "cs.jhu.edu".
+
* The first parameter is the email address.  It's the only required parameter.  If no domain is given, the domain is assumed to be "cs.jhu.edu".
 
** <code><nowiki>{{mailto|support}}</nowiki></code> → {{mailto|support}}
 
** <code><nowiki>{{mailto|support}}</nowiki></code> → {{mailto|support}}
* The second parameter gives alternate text to display instead of the email address.
+
* If you give a domain, the entire address will be used as-is.
** <code><nowiki>{{mailto|steve|Steve DeBlasio}}</nowiki></code> → {{mailto|steve|Steve DeBlasio}}
+
** <code><nowiki>{{mailto|postmaster@jhu.edu}}</nowiki></code> → {{mailto|postmaster@jhu.edu}}
* The third parameter gives an alternate domain.
+
* The optional second parameter gives alternate text to display instead of the email address.
** <code><nowiki>{{mailto|pgold3|Phil Gold|jhu.edu}}</nowiki></code> → {{mailto|pgold3|Phil Gold|jhu.edu}}
+
** <code><nowiki>{{mailto|support|CS IT Support}}</nowiki></code> → {{mailto|support|CS IT Support}}
* If you want to change the domain without providing alternate link text, use the third parameter's name, "domain".
+
* For completeness of the examples (and for testing the template), if the first parameter is omitted, an error is displayed.
** <code><nowiki>{{mailto|pgold3||jhu.edu}}</nowiki></code> → {{mailto|pgold3|domain=jhu.edu}}
+
** <code><nowiki>{{mailto}}</nowiki></code> → {{mailto}}
</noinclude><includeonly>[mailto:{{{1}}}@{{{3|cs.jhu.edu}}} {{{2|{{{1}}}@{{{3|cs.jhu.edu}}}}}}]</includeonly>
+
** <code><nowiki>{{mailto|}}</nowiki></code> → {{mailto|}}
 +
** <code><nowiki>{{mailto||Test}}</nowiki></code> → {{mailto||Test}}
 +
</noinclude><includeonly>{{#if:{{{1|}}}|[mailto:{{#if:{{#pos:{{{1}}}|@}}|{{{1}}}|{{{1}}}@cs.jhu.edu}} {{#if:{{{2|}}}|{{{2}}}|{{#if:{{#pos:{{{1}}}|@}}|{{{1}}}|{{{1}}}@cs.jhu.edu}}}}]|<strong class="error">Mailto error: No address supplied</strong>}}</includeonly>

Latest revision as of 14:46, 24 January 2020

This template simplifies the addition of clickable email addresses to a page. It takes one or two parameters, as follows:

  • The first parameter is the email address. It's the only required parameter. If no domain is given, the domain is assumed to be "cs.jhu.edu".
  • If you give a domain, the entire address will be used as-is.
  • The optional second parameter gives alternate text to display instead of the email address.
  • For completeness of the examples (and for testing the template), if the first parameter is omitted, an error is displayed.
    • {{mailto}}Mailto error: No address supplied
    • {{mailto|}}Mailto error: No address supplied
    • {{mailto||Test}}Mailto error: No address supplied