FANDOM

7,408 Pages

Template documentation (for the template shown above, sometimes hidden or invisible)

Summary

This template is a designed for inputting a single set of data into single value semantic properties. It allows for customizable rules such as Regular Expressions, data delimiters and 8 types of linking options.

Variables (default)

{{SemanticInputParser
        |value=
        |SemanticPropertyName=
        |SemanticPropertyUnit=
        |SearchByProperty=false
        |linkOptions=default
        |RegexLineCondition=
        |SemanticPropertyRegexOverride=
        |RegexPrepend=
        |RegexPrependTemplate=
        |RegexAppend=
        |RegexAppendTemplate=
        |PrependText=
        |PrependTemplate=
        |AppendText=
        |AppendTemplate=
}}

Description

  • value: This is the value passed into the template to be parsed according to the variables LineDelim, SameLineDelim, RegexPrepend, RegexAppend. It also displays a error if the parsed data does not match RegexLineCodition.
  • SemanticPropertyName: This is the name of the semantic property to assign the parsed data to
    • SearchByProperty: This boolean property creates a search icon if there are the same values for the this property
    • SemanticPropertyUnit: This is the unit of the semantic property to automatically add
  • linkOptions:
    • default, show no link if the page does not exist
    • none, never show a link
    • hide, store data only, do not show
    • Semantic Unit, Show the input with the semantic unit using the display units on the property page.
    • Wikipedia, link to wikipedia if does not exist on this wiki
    • Form:FormName, if there is no page of this name on the wiki, create a form link.
    • Query Form:FormName:TemplateName[FieldName]
    • Template:TemplateName, pass the parsed value directly into a template
  • RegexLineCondition: This sets a regex condition for each item on a line, this field is provided due to users ability to input in ways other than a regex form input.
    • SemanticPropertyRegexOverride: Setting this to 'yes', will always displays the input; but it will prevent an improper value from being entered into the semantic property.
  • RegexPrepend: This sets a regex condition for the beginning part of the line to not include in the parsing.
    • RegexPrependTemplate: This is a optional user defined template (using the variable {{{1|}}}) to pass the prepended regex text through.
  • RegexAppend: This sets a regex condition for the ending part of the line to not include in the parsing.
    • RegexAppendTemplate: This is a optional user defined template (using the variable {{{1|}}}) to pass the appended regex text through.
  • PrependText: This value is inserted in front of a line item
    • PrependTemplate: This is a optional user defined template to send the parsed data through, it is displayed before the parsed data. The first value passed is the parsed value, while the second value passed is the variable PrependText.
  • AppendText: This value is inserted behind a line item
    • AppendTemplate: This is a optional user defined template to send the parsed data through, it is displayed after the parsed data. The first value passed is the parsed value, while the second value passed is the variable AppendText.

Requirements

  1. http://www.mediawiki.org/wiki/Extension:Regex_Fun
  2. http://www.mediawiki.org/wiki/Extension:Variables
  3. http://www.mediawiki.org/wiki/Extension:Semantic_Forms (#arraymap parser)
  4. http://www.mediawiki.org/wiki/Extension:Semantic_MediaWiki
  5. Template:!

Samples

These are some samples using this template and its child template Template:SemanticInputParser/Array.

Specify a single value, a single time while also incorporating a icon with the given value.
{{SemanticInputParser
   |value=Male
   |RegexLineCondition=(Male{{!}}Female)
   |linkOptions=none
   |SemanticPropertyName=Gender
   |PrependTemplate=GenderIcon
}}
Only allow digits (including decimal) (from any script)
{{SemanticInputParser/Array
   |value=50, 90.5, not a number
   |RegexLineCondition=\p{N}+(\.\p{N}+)?
   |linkOptions=none
}}
Only allow Japanese Kanji, Spaces or Punctuation
{{SemanticInputParser/Array
   |value=仙法・超大玉螺旋多連丸, some english text
   |RegexLineCondition=[\p{Han}\p{P}\p{Zs}]+
   |linkOptions=none
}}
Do not interpret end of text as part of value
{{SemanticInputParser/Array
   |value=Some Page Name (I don't want this value to be parsed), O(this will get parsed)ther page name
   |RegexAppend=\([^()\n\r]+\)
   |SemanticPropertyName=Page Name
}}
Do not interpret start of text as part of parsed value, also add measurement units using semantic property
{{SemanticInputParser/Array
   |value=5 x 5123, 5123, not.anumber
   |RegexPrepend=\d+\s+x
   |RegexLineCondition=\d+(\.\d+)?
   |SemanticPropertyName=Vernier Thrusters
   |SemanticPropertyUnit=kg
   |linkOptions=Semantic Unit
}}
You can manipulate the data before sending it to the template, this removes all data after the first ~
{{SemanticInputParser/Array
   |value={{#arraymap:{{{value|}}}|,|_SemanticInputVariable_|{{#explode:_SemanticInputVariable_|~}}|\n}}
   |LineDelim=\n
}}
Manually add Part I, or Part II as needed in front of separate variables
{{SemanticInputParser/Array
   |value={{#if:{{{height1|}}}|Part I: {{{height1}}}}}
          {{#if:{{{height2|}}}|Part II: {{{height2}}}}}
   |SemanticPropertyName=Height
   |SemanticPropertyUnit=cm
   |LineDelim=\n
   |SameLineDelim=-
   |RegexPrepend=Part I{1,2}:\s
   |linkOptions=Semantic Unit
}}
Add italics around parsed value
{{SemanticInputParser/Array
   |value=Something, Another something
   |PrependText=<i>
   |AppendText=</i>
}}
Add a line as a title using the ~ delimiter, also uses RegexPrepend for ul lists
{{SemanticInputParser/Array
   |value=~Header, *Some value, *Some other value, ~Second Header, *more info
   |RegexPrepend=(\**)
}}
Change the delimiter between data, also uses RegexPrepend for ul lists
{{SemanticInputParser/Array
   |value=information
*Other information
**Some other information
   |LineDelim=\n
   |RegexPrepend=(\**)
}}
You can define a template and pass the result of a RegexAppend or RegexPrepend to it
{{SemanticInputParser/Array
   |value=information
   |RegexAppend=~[^~\r\n]*(~[^~\r\n]*)?
   |RegexAppendTemplate=SomeTemplateName
}}

From: "Template:SomeTemplateName"

{{#if:{{#explode:{{{1|}}}|~|1}}| ({{#explode:{{{1|}}}|~|1}})}}{{#if:{{#explode:{{{1|}}}|~|2}}| <sup>({{#explode:{{{1|}}}|~|2}})</sup>}}


Insert template inside another template to create two columns for infobox (no css)
{{#if:{{{value|}}}|<nowiki/>
{{!}}-
!{{{label|}}}
{{!}}{{SemanticInputParser/Array
       |value={{{value|}}}  
       |SemanticPropertyName={{{SemanticPropertyName|}}}
       |SemanticPropertyUnit={{{SemanticPropertyUnit|}}}
       |SearchByProperty={{{SearchByProperty|}}}
       |linkOptions={{{linkOptions|default}}}
       |LineDelim={{{LineDelim|,}}}
       |NewLineDelim={{{NewLineDelim|\n\n*}}}
       |SameLineDelim={{{SameLineDelim|/}}}
       |RegexLineCondition={{{RegexLineCondition|}}}
       |RegexPrepend={{{RegexPrepend|}}}
       |RegexPrependTemplate={{{RegexPrependTemplate|}}}
       |RegexAppend={{{RegexAppend|}}}
       |RegexAppendTemplate={{{RegexAppendTemplate|}}}
       |PrependText={{{PrependText|}}}
       |PrependTemplate={{{PrependTemplate|}}}
       |AppendText={{{AppendText|}}}
       |AppendTemplate={{{AppendTemplate|}}}
    }}
}}
Insert template inside another template to create two columns for infobox
{{#if:{{{value|}}}|<nowiki/>
{{!}}-{{#if:{{{class|}}}|<nowiki/> class="{{{class|}}}"| }}
!{{#if:{{{labelclass|}}}|<nowiki/> class="{{{labelclass|}}}" <nowiki/>| }}{{!}} {{{label|}}}
   {{!}}{{#if:{{{valueclass|}}}|<nowiki/> class="{{{valueclass|}}}" <nowiki/>| }}{{!}}{{SemanticInputParser/Array
       |value={{{value|}}}  
       |SemanticPropertyName={{{SemanticPropertyName|}}}
       |SemanticPropertyUnit={{{SemanticPropertyUnit|}}}
       |SearchByProperty={{{SearchByProperty|}}}
       |linkOptions={{{linkOptions|default}}}
       |LineDelim={{{LineDelim|,}}}
       |NewLineDelim={{{NewLineDelim|\n\n*}}}
       |SameLineDelim={{{SameLineDelim|/}}}
       |RegexLineCondition={{{RegexLineCondition|}}}
       |RegexPrepend={{{RegexPrepend|}}}
       |RegexPrependTemplate={{{RegexPrependTemplate|}}}
       |RegexAppend={{{RegexAppend|}}}
       |RegexAppendTemplate={{{RegexAppendTemplate|}}}
       |PrependText={{{PrependText|}}}
       |PrependTemplate={{{PrependTemplate|}}}
       |AppendText={{{AppendText|}}}
       |AppendTemplate={{{AppendTemplate|}}}
    }}
}}

Community content is available under CC-BY-SA unless otherwise noted.