Difference between revisions of "Template:Mailto"
(Rework the template for better usability.) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <noinclude>This template simplifies the addition of clickable email addresses to a page. It takes one | + | <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 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| | + | ** <code><nowiki>{{mailto|postmaster@jhu.edu}}</nowiki></code> → {{mailto|postmaster@jhu.edu}} |
− | * | + | * The optional second parameter gives alternate text to display instead of the email address. |
− | ** <code><nowiki>{{mailto| | + | ** <code><nowiki>{{mailto|support|CS IT Support}}</nowiki></code> → {{mailto|support|CS IT Support}} |
− | + | * For completeness of the examples (and for testing the template), if the first parameter is omitted, an error is displayed. | |
− | ** <code><nowiki>{{mailto| | + | ** <code><nowiki>{{mailto}}</nowiki></code> → {{mailto}} |
− | </noinclude><includeonly>[mailto:{{{1}}}@{{{ | + | ** <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".
{{mailto|support}}
→ support@cs.jhu.edu
- If you give a domain, the entire address will be used as-is.
{{mailto|postmaster@jhu.edu}}
→ postmaster@jhu.edu
- The optional second parameter gives alternate text to display instead of the email address.
{{mailto|support|CS IT Support}}
→ CS IT Support
- 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