Template:Val: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>Headbomb
m Reverted edits by Headbomb (talk) to last version by Quondum
meta>Cpiral
New START UNITS section
Line 78: Line 78:


START UNITS
START UNITS
 
-->{{#if:{{{up|}}}{{{upl|}}}
-->{{#if:{{{up|}}}{{{upl|}}}<!--
  |
 
  {{#if:{{{u|}}}
    If there is a up or upl, put brackets around any u or ul with a slash.
    |
 
    {{#ifexpr:{{#invoke:String|find|source={{{u}}}|target=[./*]|plain=false}}
  -->|{{#if:{{{u|}}}|{{val/units|{{{u}}}|nbsp|(|)}}}}<!--
      |
  -->{{#if:{{{ul|}}}|{{val/unitswithlink|{{{ul}}}|nbsp|(|)|ls={{{long scale}}}}}}}<!--
      {{#invoke:String|replace
 
        |source =
    Add the slash and after it put brackets around any up or upl with a dot or another slash.
          {{#invoke:String|replace
 
          <!--&nbsp;[[title|markup]]: & (or [) is 1st, [ is 7th (or 1st)-->
  -->{{#if:{{{up|}}}<!--  
            |source = {{Val/units/sandbox|{{{u}}}}}
    -->|{{val/units|{{{up}}}|#47|(|)|(|)}}<!--  
            |pattern = %[%[.+{{!}} <!--keeps &nbsp;, but compare others -->
    -->|{{val/unitswithlink|{{{upl}}}|#47|(|)|(|)|ls={{{long scale}}}}}<!--  
            |replace = (
  -->}}<!--
            |plain = false
 
          }}
    No brackets are needed if there is no up or upl, just add the non-breaking space.
        |pattern = ]]
 
        |replace = )
   -->|{{#if:{{{u|}}}|{{val/units|{{{u}}}|nbsp}}}}<!--
      }}
  -->{{#if:{{{ul|}}}|{{val/unitswithlink|{{{ul}}}|nbsp|ls={{{long scale}}}}}}}<!--
      | <!-- Same thing, but without replace with parentheses -->
-->}}<!--  
      {{#invoke:String|replace
        |source =
          {{#invoke:String|replace
            |source = {{Val/units/sandbox|{{{u}}}}}
            |pattern = %[%[.+{{!}}
            |replace =
            |plain = false
          }}
        |pattern = ]]
        |replace =
      }}
    }}
  }}<!-- end up/upl AND u
-->{{#if:{{{ul|}}}   <!-- With up/upl its possible to have neither u nor ul.-->
  |
    {{#ifexpr:{{#invoke:String|find|source={{{ul}}}|target=[./*]|plain=false}}
      | <!-- Grouping parentheses -->
        {{#invoke:String|replace
          |source =
          {{#invoke:String|replace
            |source = {{Val/units/sandbox|{{{ul}}}|ls={{{long scale}}}}}
            |pattern = [ <!-- keep spacing -->
            |replace = ([
            |count = 1
          }}
          |pattern = %]%]
          |replace = ]])
          |plain = false <!-- using %]%], not ]], prevents code mangle -->
        }}
      | <!-- normal call -->
      {{val/units/sandbox|{{{ul}}}|ls = {{{long scale}}}}}
    }}
  }}<!-- End up/upl AND ul
-->{{#if:{{{up|}}}
    |
    {{#ifexpr:{{#invoke:String|find|source={{{up}}}|target=[./*]|plain=false}}
      |
      {{#invoke:String|replace
        |source =
          {{#invoke:String|replace
            |source = {{Val/units/sandbox|{{{up}}}}}
            |pattern = .*%[%[.+{{!}} <!-- remove spacing -->
            |replace = /(
            |plain = false
          }}
        |pattern = ]]
        |replace = )
      }}
      | <!-- Same thing, but without replace with parentheses -->
      {{#invoke:String|replace
        |source =
          {{#invoke:String|replace
            |source = {{Val/units/sandbox|{{{up}}}}}
            |pattern = .*%[%[.+{{!}}
            |replace = /
            |plain = false
          }}
        |pattern = ]]
        |replace =
      }}
    }}
  | <!-- upl -->
    {{#ifexpr:{{#invoke:String|find|source={{{upl}}}|target=[./*]|plain=false}}
      |
      {{#invoke:String|replace
        |source =
          {{#invoke:String|replace
            |source = {{Val/units/sandbox|{{{upl}}}}}
            |pattern = .-%[ <!-- remove spacing -->
            |replace = /([
            |plain = false
            |count = 1
          }}
        |pattern = %]%]
        |replace = ]])
        |plain = false
      }}
      | <!-- Same thing, but without replace with parentheses -->
      {{#invoke:String|replace
        |source = {{val/units/sandbox|{{{upl}}}}}
        |pattern = .-%[ <!-- remove spacing: PCRE is .*?[ -->
        |replace = /[
        |plain = false
        |count = 1
      }}
    }}
   }}
| <!-- No up/upl -->
  {{#if:{{{u|}}}
    |
      {{#invoke:String|replace
        |source =
          {{#invoke:String|replace
            |source = {{val/units/sandbox|{{{u}}}}}
            |pattern = %[%[.+{{!}} <!-- keep unit spacing -->
            |replace =
            |plain = false
          }}
        |pattern = ]]
        |replace =
      }}
  }}<!--
  -->{{#if:{{{ul|}}}
    |{{val/units/sandbox|{{{ul}}}|ls = {{{long scale}}}}}
  }}
}}<!-- end up/upl
END UNITS
END UNITS



Revision as of 09:10, 2 June 2015