Difference between revisions of "Template:Cite"

From AlchemistryWiki
Jump to navigation Jump to search
m
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{#iferror: {{#tag:ref|name={{{1}}} }} | {{#tag:ref| {{{2}}} - [{{{3}}} Find at Cite-U-Like]| name={{{1}}} }} | {{#tag:ref|name={{{1}}} }} }}  
+
<includeonly>{{#if:{{#pos:<noinclude>{{#tag:ref||name={{{1}}} <references /> }}</noinclude>|Cite error|0}}
 +
|{{#if:{{{2|}}}
 +
  |{{#if:{{{3|}}}
 +
  |{{#tag:ref|{{{2}}} - {{URL |{{{3}}} | Find at Cite-U-Like}} | name={{{1}}} }}
 +
  |{{#tag:ref|{{{2}}} | name={{{1}}} }}
 +
  }}
 +
  |{{#tag:ref||name={{{1}}} }}<!--Should Throw error-->
 +
  }}
 +
|{{#tag:ref||name={{{1}}} }}  
 +
}}</includeonly><!--
  
<noinclude>
+
--><noinclude>
<hr />
+
'''USAGE:'''
This template is designed to be used in the following way:
+
<nowiki>{{Cite | SHORTCUT NAME TO USE LATER | FULL NORMAL CITATION | CITE-U-LIKE LINK}}</nowiki>
 
 
<nowiki>{{Cite | SHORTCUT NAME TO USE LATER | FULL NORMAL CITATION | CITE-U-LIKE LINK}}</nowiki>
 
  
 
It should be noted that this page does have a "references" at the bottom of it, but that is not part of the template, '''you will need to include a <nowiki>"<references />"</nowiki> at the end of your document'''
 
It should be noted that this page does have a "references" at the bottom of it, but that is not part of the template, '''you will need to include a <nowiki>"<references />"</nowiki> at the end of your document'''
Line 11: Line 18:
 
If you have already used this reference name once, then you can simply use the <nowiki>{{Cite | REF NAME}}</nowiki>
 
If you have already used this reference name once, then you can simply use the <nowiki>{{Cite | REF NAME}}</nowiki>
  
{{Reflist hide}}
+
For those of you wanting to see how and why this works, please check the following pages (in no particular order):
 +
[http://www.mediawiki.org/wiki/Extension:StringFunctions String Parsing],
 +
[http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23if Parser Logic],
 +
[https://www.mediawiki.org/wiki/Help:Magic_words#Miscellaneous Magic words for refs inside templates],
 +
[http://en.wikipedia.org/wiki/Help:Template#Noinclude.2C_includeonly.2C_and_onlyinclude includeonly and noinclude],
 +
[http://www.mediawiki.org/wiki/Help:Parser_functions_in_templates to see why non-defined params are treated as whitespace],
 +
And understanding that the <nowiki><!-- ... -></nowiki> is the html equivalent of a comment and without it, the extra whitespace would be parsed into the template as well. The noinclude inside the #pos word is to ensure the citation is not done twice.
 +
 
 +
'''TESTS'''
 +
This is a self consistent Test{{Cite | id | fullcite | CUL}} ...Test an id and cite without citulike {{Cite | citeid | A citation}} ... this should replicate the first citation {{Cite|id}} and this should target the second real citation{{cite|citeid}}
 +
 
 +
This is a generic ref tag test that should break(not template)<ref name=testberak></ref>. This is a break test with template{{Cite | break }}. This should also break (template){{cite |testbreak}}.
 +
 
 +
<references />
  
 
</noinclude>
 
</noinclude>

Latest revision as of 11:35, 24 September 2012

USAGE:

{{Cite | SHORTCUT NAME TO USE LATER | FULL NORMAL CITATION | CITE-U-LIKE LINK}}

It should be noted that this page does have a "references" at the bottom of it, but that is not part of the template, you will need to include a "<references />" at the end of your document

If you have already used this reference name once, then you can simply use the {{Cite | REF NAME}}

For those of you wanting to see how and why this works, please check the following pages (in no particular order): String Parsing, Parser Logic, Magic words for refs inside templates, includeonly and noinclude, to see why non-defined params are treated as whitespace, And understanding that the <!-- ... -> is the html equivalent of a comment and without it, the extra whitespace would be parsed into the template as well. The noinclude inside the #pos word is to ensure the citation is not done twice.

TESTS This is a self consistent Test[1] ...Test an id and cite without citulike [2] ... this should replicate the first citation [1] and this should target the second real citation[2]

This is a generic ref tag test that should break(not template)[3]. This is a break test with template[4]. This should also break (template)[5].

  1. 1.0 1.1 fullcite - Find at Cite-U-Like
  2. 2.0 2.1 A citation
  3. Cite error: Invalid <ref> tag; no text was provided for refs named testberak
  4. Cite error: Invalid <ref> tag; no text was provided for refs named break
  5. Cite error: Invalid <ref> tag; no text was provided for refs named testbreak