Difference between revisions of "Template:FAIRWiki-Reference template code demo"

m
m
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
1) Initial: John Doe, ''Funky Book Title'' (Acme Co.), {{{start}}}–{{{end}}}.
+
John Doe, ''Funky Book Title'' (Acme Co.){{#if:{{{end|}}}|, {{{start}}}–{{{end}}}.|{{#if:{{{start|}}}|, {{{start}}}.|{{#if:{{{pages|}}}|, {{{pages}}}.|.}}}}}}
  
2) Start and finish: John Doe, ''Funky Book Title'' (Acme Co.){{#if:{{{end|}}}|{{{start}}}|, {{{start}}}–{{{end}}}.}}
+
This is demo code for the old-style templates which converts them to new-style without breaking them.
  
3) Start only: John Doe, ''Funky Book Title'' (Acme Co.), {{{start}}}–{{{end}}}.
+
Send code to test it by calling:
  
4) Pages (final): John Doe, ''Funky Book Title'' (Acme Co.), {{{start}}}–{{{end}}}.
+
<nowiki>{{FAIRWiki-Reference template code demo|start=5|end=10}}</nowiki>
----
+
 
{{#if:{{{start|}}}|Start exists: {{{start}}}|Start does not exist}}
+
A graphic comment on the code is available by clicking [http://pool.fairmormon.org/File:Page_number_template_%28old_to_new_version%29_code_documentation.PNG here].  Also, click '''edit''' tab above to see more comments.
 +
 
 +
<!--This template demos how the old page number templates have been changed so old references still work, but new ones will also work.
 +
 
 +
The old style looked like this:
 +
 
 +
{{TPJS|start=5|end=10}}
 +
 
 +
This would give Teachings of the Prophet Joseph Smith, pp. 5-10.
 +
 
 +
There was also
 +
 
 +
{{TPJS1|start=5}}
 +
 
 +
Which would give Teachings of the Prophet Joseph Smith, pp. 5.
 +
 
 +
And sometimes
 +
 
 +
{{TPJS0}}
 +
 
 +
Which would give Teachings of the Prophet Joseph Smith.  [No page numbers.]
 +
 
 +
This is cumbersome.  The new system uses a more rational naming approach, as follows:
 +
 
 +
{{Book:Author:Title|pages=5-10}}
 +
 
 +
So, TPJS might be
 +
 
 +
{{Book:Smith:Teachings of the Prophet Joseph Smith|pages=5-10}}
 +
 
 +
This edit allows all four templates to redirect to the same template, and still display properly. So, the template:
 +
 
 +
a) checks to see if the argument {{{end}}} is sent.  If it is, assume this is {{TPJS}}, and display {{{start}}}&ndash;{{{end}}}.
 +
b) if {{{end}}} does not exist, see if {{{start}}} exists.  If so, assume this is {{TPJS1}} and display {{{start}}} only.
 +
c) if {{{end}}} and {{{start}}} do not exist, see if {{{pages}}} exists.  If so, this is the new style, and display {{{pages}}}.
 +
d) if {{end}}}, {{{start}}}, and {{{pages}}} do not exist, assume the book is referred to without page number at all.-->

Latest revision as of 21:32, 22 April 2010

John Doe, Funky Book Title (Acme Co.).

This is demo code for the old-style templates which converts them to new-style without breaking them.

Send code to test it by calling:

{{FAIRWiki-Reference template code demo|start=5|end=10}}

A graphic comment on the code is available by clicking here. Also, click edit tab above to see more comments.