Help:Templates: Difference between revisions

Jump to navigation Jump to search
m
→‎To include or not include: Do not worry about all that text...
m (→‎To include or not include: ...and another one)
m (→‎To include or not include: Do not worry about all that text...)
Line 106: Line 106:
Sometimes you have content in a template that you do not want to be transcluded or that you want to have transcluded but not included in the template.  Consider for example the template documentation, of course you would not want it to be on every page the template is used on, also, sometimes you want a template to add a category to the page it is used on, but not to the template itself. This can be done using the <tt><nowiki><noinclude></nowiki></tt> and <tt><nowiki><includeonly></nowiki></tt> tags.
Sometimes you have content in a template that you do not want to be transcluded or that you want to have transcluded but not included in the template.  Consider for example the template documentation, of course you would not want it to be on every page the template is used on, also, sometimes you want a template to add a category to the page it is used on, but not to the template itself. This can be done using the <tt><nowiki><noinclude></nowiki></tt> and <tt><nowiki><includeonly></nowiki></tt> tags.


To go back to the ''Template:Hello'' template, the below example shows how ''Category:Pages that says hello'' is added to the page that uses the template but not to the template and how the documentation and ''Category:Hello templates'' is added to the template, but not the page it will be used on.  Note that both the <tt><nowiki><includeonly></nowiki></tt> and <tt><nowiki><noinclude></nowiki></tt> tags are right behind the text of the template, as a having a line break would cause a line break when the template is used. Here is the full ''Template:Hello'':
To go back to the ''Template:Hello'' template, the below example shows how ''Category:Pages that says hello'' is added to the page that uses the template but not to the template and how the documentation and ''Category:Hello templates'' is added to the template, but not the page it will be used on.  Note that both the <tt><nowiki><includeonly></nowiki></tt> and <tt><nowiki><noinclude></nowiki></tt> tags are right behind the text of the template, as a having a line break would cause a line break when the template is used.
 
Here is the full ''Template:Hello''.  Do not worry about typing all that text, {{tl|informative template}} is one of the templates with pre-filled examples you can copy and paste into the template you are editing.


  <nowiki>Hello, {{{1|}}}{{{2|stranger}}}!<includeonly>[[Category:Pages that says hello]]</includeonly><noinclude>
  <nowiki>Hello, {{{1|}}}{{{2|stranger}}}!<includeonly>[[Category:Pages that says hello]]</includeonly><noinclude>

Navigation menu