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

m
m
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}}}–{{{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.){{#if:{{{end|}}}|, {{{start}}}–{{{end}}}.|{{#if:{{{start|}}}|, {{{start}}}.}}}}
+
A graphic comment on the code is available by clicking [[here]].
  
4) Pages (final): John Doe, ''Funky Book Title'' (Acme Co.){{#if:{{{end|}}}|, {{{start}}}–{{{end}}}.|{{#if:{{{start|}}}|, {{{start}}}.|{{#if:{{{pages|}}}|, {{{pages}}}.|.}}}}}}
+
<!--This template demos how the old page number templates have been changed so old references still work, but new ones will also work.
  
'''''Debugging'''''
+
The old style looked like this:
*{{#if:{{{start|}}}|Start exists: {{{start}}}|Start does not exist}}
+
 
*{{#if:{{{end|}}}|End exists: {{{end}}}|End does not exist}}
+
{{TPJS|start=5|end=10}}
*{{#if:{{{pages|}}}|Pages exists: {{{pages}}}|Pages does not exist}}
+
 
 +
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.-->

Revision as of 20:27, 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.

A graphic comment on the code is available by clicking here.