2014-01-24

Create display enchantments cell template // uses loops // lot of logic to determine enchantment templates to be used

New page

<noinclude>

__NOTOC__

== Usage ==

<pre>

{{ ItemDisplayEnchantmentsCell

| ( Value ) = Semicolon separated list of enchantments found on the item

If the entire string is an item enchantment template, that is injected

Otherwise, if the string excluding the first "word" is a template, that is injected with the first word as a parameter

Otherwise, if the string excluding the last "word" is a template, that is injected with the last word as a parameter

Otherwise, if the first word of the string is a template, that is injected with all other words as parameters ( up to 5 )

Otherwise, unable to determine enchantments template error is displayed

| ( suffix ) = Suffix to add to each element during generation

defaults to <br /> if not defined

| ( element separator ) = Character used to seperate elements in the list

defaults to ; if not defined

| ( comment separator ) = Character used to indicate text that should be treated as comment

defaults to / if not defined

text prior to comment separator will be displayed as link

}}

</pre>

== Examples ==

<nowiki>{{ItemDisplayEnchantmentsCell | Deathblock }}</nowiki> = <br />{{ItemDisplayEnchantmentsCell | Deathblock }}<br /><br />

<nowiki>{{ItemDisplayEnchantmentsCell | Deathblock I }}</nowiki> = <br />{{ItemDisplayEnchantmentsCell | Deathblock I }}<br /><br />

<nowiki>{{ItemDisplayEnchantmentsCell | Res 10 Lightning; Enhancement bonus 5; Dmg screaming }}</nowiki> = <br />{{ItemDisplayEnchantmentsCell | Res 10 Lightning; Enhancement bonus 5; Dmg screaming }}<br /><br />

<nowiki>{{ItemDisplayEnchantmentsCell | }}</nowiki> = <br />{{ItemDisplayEnchantmentsCell | }}<br /><br />

<nowiki>{{ItemDisplayEnchantmentsCell }}</nowiki> = <br />{{ItemDisplayEnchantmentsCell }}<br /><br />

== Categorization ==

[ ( Enchantment name ) items ] child of [[:Category:Items by enchantment]] injected by various enchantment templates

[[Category:Item Display templates]]

</noinclude><includeonly>

{{#vardefine: Position <!-- set starting element position to 0 -->

| 0 }}{{

#vardefine: CurrentElementValue <!-- set starting element value to first element in list -->

| {{#explode: {{{1|}}} | {{{3|;}}} | {{#var: Position}} }} }}{{

#while:

| {{#var: CurrentElementValue}} <!-- execute loop *IF* element value is populated -->

<!-- if on second or greater element, prefix it with suffix parameter -->

|{{#ifexpr: {{#var: Position}} > 0 | {{{2|<br />}}}}} {{#ifexist: Template:{{#var: CurrentElementValue}}

<!-- Template matching full string exists. Transclude matching template page -->

| {{ {{#var: CurrentElementValue}}}}

<!-- No template matching full string exists. Check next in order -->

| {{#ifexist: Template:{{#replace: {{#var: CurrentElementValue}} | {{#explode:{{#var: CurrentElementValue}} | | 0 }} }}

<!-- Template page matching string minus first word exists. Transclude that template page and send first word as parameter -->

| {{ {{#replace: {{#var: CurrentElementValue}} | {{#explode:{{#var: CurrentElementValue}} | | 0 }} }} | {{#explode:{{#var: CurrentElementValue}} | | 0 }}}}

<!-- No template page matching string minus first word exists. Check next in order -->

| {{#ifexist: Template:{{#replace: {{#var: CurrentElementValue}} | {{#explode:{{#var: CurrentElementValue}} | | -1 }} }}

<!-- Template page matching string minus last word exists. Transclude that template page and send last word as parameter -->

| {{ {{#replace: {{#var: CurrentElementValue}} | {{#explode:{{#var: CurrentElementValue}} | | -1 }} }} | {{#explode:{{#var: CurrentElementValue}} | | -1 }}}}

<!-- No template page matching string minus last word exists. Check next in order -->

| {{#ifexist: Template:{{#explode:{{#var: CurrentElementValue}} | | 0 }}

<!-- Template page matching first word of string exists. Transclude that template page and all words ( up to 5 ) send as parameters -->

| {{ {{#explode:{{#var: CurrentElementValue}} | | 0 }} | {{#explode:{{#var: CurrentElementValue}} | | 1 }} | {{#explode:{{#var: CurrentElementValue}} | | 2 }} | {{#explode:{{#var: CurrentElementValue}} | | 3 }} | {{#explode:{{#var: CurrentElementValue}} | | 4 }} | {{#explode:{{#var: CurrentElementValue}} | | 5 }}}}

<!-- No template page matching string combinations found. Display error message -->

| Unable to determine correct template for enchantment {{#var: CurrentElementValue}}

}}

}}

}}

}} {{<!-- parse out anything after comment separator and display element as page link -->

#if: {{#pos: {{#explode: {{{1|}}} | {{{3|;}}} | {{#var: Position}} }}| {{{4|/}}} }} <!-- if a comment separator is found in the element, display comment -->

| {{#sub: {{#explode: {{{1|}}} | {{{3|;}}} | {{#var: Position}} }} | {{#expr: {{#pos: {{#explode: {{{1|}}} | {{{3|;}}} | {{#var: Position}} }} | {{{4|/}}} }} + 1 }} | 0 }} }}{{

#vardefine: Position <!-- increment element position -->

| {{#expr: {{#var: Position}} + 1 }} }}{{

#vardefine: CurrentElementValue <!-- repopulate element value for next loop iteration -->

| {{#explode: {{{1}}} | {{{3|;}}} | {{#var: Position}} }} }} }}</includeonly>

Show more