Lompat ke isi

Bantuan:Fungsi parser: Perbedaan antara revisi

Dari Wikipedia bahasa Indonesia, ensiklopedia bebas
Konten dihapus Konten ditambahkan
←berbeda
RaFaDa20631 (bicara | kontrib)
 
(12 revisi perantara oleh 6 pengguna tidak ditampilkan)
Baris 3: Baris 3:
| text = Ini merupakan sebuah salinan dari [[:m:Help:Parser function|di Meta]]. '''Jangan menambahi apa pun.'''
| text = Ini merupakan sebuah salinan dari [[:m:Help:Parser function|di Meta]]. '''Jangan menambahi apa pun.'''
}}
}}
{{Templat:Bantuan:Bantuan/seri tab}}

{{Templat:Bantuan:Bantuan/sidebar}}
"'''Fungsi parser'''" ({{asal kata|Inggris|parser function}}) (berbeda dengan ekstensi ''ParserFunctions'' yang merupakan kumpulan fungsi parser) adalah semacam templat yang memberikan nilai sesuai dengan paling sedikit satu parameter tak bernama, yang dipisahkan dari nama fungsi menggunakan tanda titik dua "''':'''"; seperti templat biasa, fungsi ini mungkin memiliki beberapa parameter, masing-masing diawali dengan garis tegak "'''|'''". Sintaks dapat ditulis dengan atau tanpa tanda pagar "'''#'''" di awalnya:
"'''Fungsi parser'''" ({{asal kata|Inggris|parser function}}) (berbeda dengan ekstensi ''[[Bantuan:ParserFunctions|ParserFunctions]]'' yang merupakan kumpulan fungsi parser) adalah semacam templat yang memberikan nilai sesuai dengan paling sedikit satu parameter tak bernama, yang dipisahkan dari nama fungsi menggunakan tanda titik dua "''':'''"; seperti templat biasa, fungsi ini mungkin memiliki beberapa parameter, masing-masing diawali dengan garis tegak "'''|'''". Sintaks dapat ditulis dengan atau tanpa tanda pagar "'''#'''" di awalnya:


:<nowiki>{{</nowiki>namafungsi: argumen 1 | argumen 2 | argumen 3...}}
:<nowiki>{{</nowiki>namafungsi: argumen 1 | argumen 2 | argumen 3...}}


Untuk daftar kata-kata istimewa di Wikipedia, lihat pula [[:m:Help:Magic words]]
Untuk daftar kata-kata istimewa di Wikipedia, lihat pula [[Kata magis]] atau [[:m:Help:Magic words]] (Inggris, lebih sering dimutakhirkan)

Untuk fungsi parser yang diawali tagar di depannya, sepert #expr:, #if:, #time, dsb, baca penggunaannya di [[Bantuan:ParserFunctions]]


== Pemformatan ==
== Pemformatan ==


=== LC - huruf kecil ===
=== LC - huruf kecil ===
;(''LowerCase'') atau huruf kecil.
;(''LowerCase'') atau huruf kecil.
:Membuat teks menjadi huruf kecil dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.
:Membuat teks menjadi huruf kecil dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.


Baris 20: Baris 23:


=== UC - huruf besar ===
=== UC - huruf besar ===
;(''UpperCase'') atau huruf besar.
;(''UpperCase'') atau huruf besar.
:Membuat teks menjadi huruf besar dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.
:Membuat teks menjadi huruf besar dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.


Baris 27: Baris 30:


=== LCFIRST - huruf pertama kecil ===
=== LCFIRST - huruf pertama kecil ===
;(''LowerCaseFirst'') atau huruf pertama huruf kecil.
;(''LowerCaseFirst'') atau huruf pertama huruf kecil.
:Membuat huruf pertama teks menjadi huruf kecil dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.
:Membuat huruf pertama teks menjadi huruf kecil dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.


Baris 33: Baris 36:


=== UCFIRST - huruf pertama besar ===
=== UCFIRST - huruf pertama besar ===
;(''UpperCaseFirst'') atau huruf pertama huruf besar.
;(''UpperCaseFirst'') atau huruf pertama huruf besar.
:Membuat huruf pertama teks menjadi huruf besar dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.
:Membuat huruf pertama teks menjadi huruf besar dan menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks.


Baris 39: Baris 42:


=== URLENCODE ===
=== URLENCODE ===
Menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks, dan mengkonversi teks menjadi format yang ramah-URL<!-- by replacing spaces with "+" and other url formatting characters with their escaped equivalents: -->
Menghilangkan karakter ''newline'' dan spasi di awal dan akhir teks, dan mengkonversi teks menjadi format yang ramah-URL<!-- by replacing spaces with "+" and other url formatting characters with their escaped equivalents: -->


{{nowiki|urlencode:|2=halo dunia ?&=#/:}}.
{{nowiki|urlencode:|2=halo dunia ?&=#/:}}.


*{{nowiki|urlencode:|"#$%&<!->'()*,;?[]^`{} }} [http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;urlencode:{&#123;subst:"#$%&<!->'()*,;?[%5D^`{}&#125;}&#125;}
* {{nowiki|urlencode:|"#$%&<!->'()*,;?[]^`{} }} [http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={{urlencode:<blockquote class="templatequote"><div class="Bug6200">{{error|Error: No text given for quotation (or equals sign used in the actual argument to an unnamed parameter)}}</div>{{#if:
|<div class="templatequotecite">&#8212;{{#if:
*{{nowiki|urlencode:|<}} [http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;urlencode:<&#125;}] (preposesor yang lama tidak menghasilkan kode %3C dari simbol tersebut, tapi kode dari HTML &amp;lt;)
|,&nbsp;<cite></cite>
*{{nowiki|urlencode:|>}} [http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;urlencode:>&#125;}] (preposesor yang lama tidak menghasilkan kode %3E dari simbol tersebut, tapi kode dari HTML &amp;lt;)
}}</div>
*{{nowiki2|urlencode:|!}}
}}</blockquote>}}}
* {{nowiki|urlencode:|<}} [http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={{urlencode:<}}] (preposesor yang lama tidak menghasilkan kode %3C dari simbol tersebut, tapi kode dari HTML &amp;lt;)
* {{nowiki|urlencode:|>}} [http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={{urlencode:>}}] (preposesor yang lama tidak menghasilkan kode %3E dari simbol tersebut, tapi kode dari HTML &amp;lt;)
* {{nowiki2|urlencode:|!}}


NB: Untuk pranala ''di dalam'' suatu halaman, gunakan [[#ANCHORENCODE|<nowiki>{{anchorencode}}</nowiki>]]
NB: Untuk pranala ''di dalam'' suatu halaman, gunakan [[#ANCHORENCODE|<nowiki>{{anchorencode}}</nowiki>]]
Baris 54: Baris 61:


== NS - ruang nama ==
== NS - ruang nama ==
;(''NameSpace'') atau Ruang Nama.
;(''NameSpace'') atau Ruang Nama.
:Memberikan nama Ruang Nama<!-- Gives the namespace name for a given [[Help:Namespace|namespace]] number or name: -->
:Memberikan nama Ruang Nama<!-- Gives the namespace name for a given [[Help:Namespace|namespace]] number or name: -->


{| class="wikitable"
{| class="wikitable"
! Kode{{br}}dengan Angka !! Hasil{{br}}dengan Angka
! Kode{{br}}dengan Angka !! Hasil{{br}}dengan Angka
! Kode{{br}}dengan Nama !! Hasil{{br}}dengan Nama
! Kode{{br}}dengan Nama !! Hasil{{br}}dengan Nama
|-
|-
| {{nowiki3|ns:|-2}}
| {{nowiki3|ns:|-2}}
| {{nowiki3|ns:|Media}}
| {{nowiki3|ns:|Media}}
|-
|-
| {{nowiki3|ns:|-1}}
| {{nowiki3|ns:|-1}}
| {{nowiki3|ns:|Special}}
| {{nowiki3|ns:|Special}}
|-
|-
| {{nowiki3|ns:|0}}
| {{nowiki3|ns:|0}}
| {{nowiki3|ns:|0}}
| {{nowiki3|ns:|0}}
|-
|-
| {{nowiki3|ns:|1}}
| {{nowiki3|ns:|1}}
| {{nowiki3|ns:|Talk}}
| {{nowiki3|ns:|Talk}}
|-
|-
| {{nowiki3|ns:|2}}
| {{nowiki3|ns:|2}}
| {{nowiki3|ns:|User}}
| {{nowiki3|ns:|User}}
|-
|-
| {{nowiki3|ns:|3}}
| {{nowiki3|ns:|3}}
| {{nowiki3|ns:|User_talk}}
| {{nowiki3|ns:|User_talk}}
|-
|-
| {{nowiki3|ns:|4}}
| {{nowiki3|ns:|4}}
| {{nowiki3|ns:|Project}}
| {{nowiki3|ns:|Project}}
Baris 84: Baris 91:
| {{nowiki3|ns:|5}}
| {{nowiki3|ns:|5}}
| {{nowiki3|ns:|Project_talk}}
| {{nowiki3|ns:|Project_talk}}
|-
|-
| {{nowiki3|ns:|6}}
| {{nowiki3|ns:|6}}
| {{nowiki3|ns:|Image}}
| {{nowiki3|ns:|Image}}
Baris 90: Baris 97:
| {{nowiki3|ns:|7}}
| {{nowiki3|ns:|7}}
| {{nowiki3|ns:|Image_talk}}
| {{nowiki3|ns:|Image_talk}}
|-
|-
| {{nowiki3|ns:|8}}
| {{nowiki3|ns:|8}}
| {{nowiki3|ns:|MediaWiki}}
| {{nowiki3|ns:|MediaWiki}}
Baris 96: Baris 103:
| {{nowiki3|ns:|9}}
| {{nowiki3|ns:|9}}
| {{nowiki3|ns:|MediaWiki_talk}}
| {{nowiki3|ns:|MediaWiki_talk}}
|-
|-
| {{nowiki3|ns:|10}}
| {{nowiki3|ns:|10}}
| {{nowiki3|ns:|Template}}
| {{nowiki3|ns:|Template}}
Baris 102: Baris 109:
| {{nowiki3|ns:|11}}
| {{nowiki3|ns:|11}}
| {{nowiki3|ns:|Template_talk}}
| {{nowiki3|ns:|Template_talk}}
|-
|-
| {{nowiki3|ns:|12}}
| {{nowiki3|ns:|12}}
| {{nowiki3|ns:|Help}}
| {{nowiki3|ns:|Help}}
Baris 108: Baris 115:
| {{nowiki3|ns:|13}}
| {{nowiki3|ns:|13}}
| {{nowiki3|ns:|Help_talk}}
| {{nowiki3|ns:|Help_talk}}
|-
|-
| {{nowiki3|ns:|14}}
| {{nowiki3|ns:|14}}
| {{nowiki3|ns:|Category}}
| {{nowiki3|ns:|Category}}
Baris 116: Baris 123:
|-
|-
! colspan="4" align="center" | Ruang Nama dengan nomor 100 ke atas dapat dikustomisasi di masing-masing situs wiki
! colspan="4" align="center" | Ruang Nama dengan nomor 100 ke atas dapat dikustomisasi di masing-masing situs wiki
|-
|-
| {{nowiki3|ns:|100}}
| {{nowiki3|ns:|100}}
| {{nowiki3|ns:|Portal}}
| {{nowiki3|ns:|Portal}}
Baris 124: Baris 131:
|}
|}


<!--
<!-- hasilnya tidak seharusnya seperti ini http://meta.wikimedia.org/w/index.php?title=Special:ExpandTemplates&input=%22%7B%7Bns%3A%7B%7Bns%3A12%7D%7D_talk%7D%7D%22. Lihat di halaman meta [[:m:Help:Parser_function#NS]] -->
See [[Help:Variable]] for more canonical names like "'''<code>project</code>'''" and "'''<code>talk</code>'''".
Benar:
*{{nowiki2|ns:Pembicaraan_|ns:12}}.[http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;ns:Pembicaraan_{&#123;ns:12&#125;}&#125;}]
*{{nowiki2|ns:|SITENAME}}.[http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;ns:{&#123;SITENAME&#125;}}&#125;}}]
*{{nowiki2|ns:Pembicaraan_|ns:8}}.[http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;ns:Pembicaraan_{&#123;ns:8&#125;}}&#125;}}]
*{{nowiki2|ns:Pembicaraan |ns:8}}[http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;ns:Pembicaraan+{&#123;ns:8&#125;}}&#125;}}].
Salah
*{{nowiki2|ns:Pembicaraan|ns:8}}.[http://wiki-indonesia.club/w/index.php?title=Special:ExpandTemplates&input={&#123;ns:Pembicaraan{&#123;ns:8&#125;}}&#125;}}]
<!--
See [[Help:Variable]] for more canonical names like "'''<tt>project</tt>'''" and "'''<tt>talk</tt>'''".


=== NS:1 ===
=== NS:1 ===


{{xpdoocc|ns:|ns:0|_talk}}, just as {{xpd|ns:_talk}}. The canonical name for the talk namespace of articles is "'''<tt>talk</tt>'''" and not "'''<tt>_talk</tt>'''". Appending "_talk" to the namespace name works for all but the main namespace.
{{xpdoocc|ns:|ns:0|_talk}}, just as {{xpd|ns:_talk}}. The canonical name for the talk namespace of articles is "'''<code>talk</code>'''" and not "'''<code>_talk</code>'''". Appending "_talk" to the namespace name works for all but the main namespace.


The following constructs work:
The following constructs work:
Baris 146: Baris 145:
*{{xpdoocc|ns:|ns:1}}.
*{{xpdoocc|ns:|ns:1}}.


<!-- Please do not change the permanent anchor for
<!-- Please do not change the permanent anchor for
[[m:Help:Parser functions##ns:0 gives null string]]
[[m:Help:Parser functions##ns:0 gives null string]]
even if you change the section title.
even if you change the section title.
Baris 155: Baris 154:
{{xpd|ns:0}}, an empty string. This is often handy, and less vulnerable to vandalism by a compromised administrator account than a template '''void''' or similar.
{{xpd|ns:0}}, an empty string. This is often handy, and less vulnerable to vandalism by a compromised administrator account than a template '''void''' or similar.


The cryptic [[Help:magic words|magic word]] [[Help:magic words#Other|<tt><nowiki>__END__</nowiki></tt>]] is no longer supported. It formerly allowed for trailing whitespace to be included in the page save, but was removed in revision [[rev:19213|19213]].
The cryptic [[Help:magic words|magic word]] [[Help:magic words#Other|<code><nowiki>__END__</nowiki></code>]] is no longer supported. It formerly allowed for trailing whitespace to be included in the page save, but was removed in revision [[rev:19213|19213]].


In constructs like <code><nowiki>{{ {{#if: {{{T|}}} | {{{T}}} | ns:0}} }}</nowiki></code>, where parameter '''T''' is
In constructs like <code><nowiki>{{ {{#if: {{{T|}}} | {{{T}}} | ns:0}} }}</nowiki></code>, where parameter '''T''' is
normally the name of a template to be evaluated, but can be undefined or empty, <code><nowiki>{{ns:0}}</nowiki></code>
normally the name of a template to be evaluated, but can be undefined or empty, <code><nowiki>{{ns:0}}</nowiki></code>
is then a clean empty string. Without it <code><nowiki>{{}}</nowiki></code> would result in {{}}.
is then a clean empty string. Without it <code><nowiki>{{}}</nowiki></code> would result in {{}}.


Baris 171: Baris 170:
creates an entry in the TOC coded in the output HTML as
creates an entry in the TOC coded in the output HTML as
&lt;li class="toclevel-2">&lt;a href="#">&lt;span class="tocnumber">2.4&lt;/span> &lt;/a>&lt;/li>
&lt;li class="toclevel-2">&lt;a href="#">&lt;span class="tocnumber">2.4&lt;/span> &lt;/a>&lt;/li>
attempting but failing to link to the null anchor
attempting but failing to link to the null anchor
&lt;p>&lt;a name="">&lt;/a>&lt;/p>
&lt;p>&lt;a name="">&lt;/a>&lt;/p>
and with an edit link similar to this:
and with an edit link similar to this:
Baris 179: Baris 178:
=== {{ns:0}} ===
=== {{ns:0}} ===


An empty section title (with an edit link to the right) as above is obtained using, in this case, <code><nowiki>=== {{ns:0}} ===</nowiki></code>. This is dubious, but arguably better than using the same trick to get invisble section headers twice on a page. At least <tt><nowiki>/*&#160;{{ns:0}}&#160;*/</nowiki></tt> makes sense in the edit history, if there's only one section using this particular trick.
An empty section title (with an edit link to the right) as above is obtained using, in this case, <code><nowiki>=== {{ns:0}} ===</nowiki></code>. This is dubious, but arguably better than using the same trick to get invisble section headers twice on a page. At least <code><nowiki>/*&#160;{{ns:0}}&#160;*/</nowiki></code> makes sense in the edit history, if there's only one section using this particular trick.


As shown in the table of contents this and similar tricks result in non-functional links. In conjunction with <code><nowiki>__NOTOC__</nowiki></code> it's less harmful, and maybe useful to get edit links for invisible sections with categories and interlanguage links. Other possibilities for different ''invisible'' section headers:
As shown in the table of contents this and similar tricks result in non-functional links. In conjunction with <code><nowiki>__NOTOC__</nowiki></code> it's less harmful, and maybe useful to get edit links for invisible sections with categories and interlanguage links. Other possibilities for different ''invisible'' section headers:
Baris 187: Baris 186:
# <code><nowiki>=== &amp;#160; ===</nowiki></code>
# <code><nowiki>=== &amp;#160; ===</nowiki></code>
-->
-->

== URL - pranala ==
== URL - pranala ==


Baris 192: Baris 192:
| {{nowiki3|localurl:|namahalaman}}
| {{nowiki3|localurl:|namahalaman}}
|-
|-
| {&#123;<code><nowiki>localurl:halaman|query=x</nowiki></code>}}||{{localurl:halaman|query=x}}
| {{<code><nowiki>localurl:halaman|query=x</nowiki></code>}}||{{localurl:halaman|query=x}}
|-
|-
| {&#123;<code><nowiki>localurl:halaman|action=edit</nowiki></code>}}||{{localurl:halaman|action=edit}}
| {{<code><nowiki>localurl:halaman|action=edit</nowiki></code>}}||{{localurl:halaman|action=edit}}
|-
|-
| {{nowiki3|localurl:|a&b! c}}
| {{nowiki3|localurl:|a&b! c}}
|-
|-
| {{nowiki3|localurle:|a&b! c}}
| {{nowiki3|localurle:|a&b! c}}
|-
|-
| {{nowiki3|urlencode:|a&b! c}}
| {{nowiki3|urlencode:|a&b! c}}
|-
|-
| {{nowiki3|fullurl:|namahalaman}}
| {{nowiki3|fullurl:|namahalaman}}
|-
|-
| {{nowiki3|fullurl:|ab}}
| {{nowiki3|fullurl:|ab}}
|-
|-
| {{nowiki3|fullurl:|a b}}
| {{nowiki3|fullurl:|a b}}
|-
| {&#123;<code><nowiki>fullurl:ab|u=v</nowiki></code>}}||{{fullurl:ab|u=v}}
|-
| {&#123;<code><nowiki>fullurl:a b|u=v</nowiki></code>}}||{{fullurl:a b|u=v}}
|-
| {&#123;<code><nowiki>fullurl:a b|u=v w</nowiki></code>}}||{{fullurl:a b|u=v w}}
|-
| {&#123;<code><nowiki>fullurl:a&b!|u=v</nowiki></code>}}||{{fullurl:a&b!|u=v}}
|-
|-
| {&#123;<code><nowiki>fullurle:a&b!|u=v</nowiki></code>}}||{{fullurle:a&b!|u=v}}
| {{<code><nowiki>fullurl:ab|u=v</nowiki></code>}}||{{fullurl:ab|u=v}}
|-
| {{<code><nowiki>fullurl:a b|u=v</nowiki></code>}}||{{fullurl:a b|u=v}}
|-
| {{<code><nowiki>fullurl:a b|u=v w</nowiki></code>}}||{{fullurl:a b|u=v w}}
|-
| {{<code><nowiki>fullurl:a&b!|u=v</nowiki></code>}}||{{fullurl:a&b!|u=v}}
|-
| {{<code><nowiki>fullurle:a&b!|u=v</nowiki></code>}}||{{fullurle:a&b!|u=v}}
|-
|-
|colspan="2"|Dengan prefiks interwiki
|colspan="2"|Dengan prefiks interwiki
|-
|-
| {&#123;<code><nowiki>fullurl:m:a b|u=v</nowiki></code>}}||{{fullurl:m:a b|u=v}}
| {{<code><nowiki>fullurl:m:a b|u=v</nowiki></code>}}||{{fullurl:m:a b|u=v}}
|-
|-
| {&#123;<code><nowiki>fullurl:m:ab|u=v</nowiki></code>}}||{{fullurl:m:ab|u=v}}
| {{<code><nowiki>fullurl:m:ab|u=v</nowiki></code>}}||{{fullurl:m:ab|u=v}}
|}
|}


Baris 229: Baris 229:
For interwiki links localurl and fullurl give the same:
For interwiki links localurl and fullurl give the same:
{| class="wikitable"
{| class="wikitable"
|-
|-
| {{nowiki3|localurl:|w:a}}
| {{nowiki3|localurl:|w:a}}
|-
|-
| {{nowiki3|fullurl:|w:a}}
| {{nowiki3|fullurl:|w:a}}
|}
|}
;Bagian ini belum diterjemahkan
;Bagian ini belum diterjemahkan

<poem>
The parser function <tt>localurl:<tt> replaces spaces by underscores and special characters by escape codes, e.g. {&#123;localurl:a !&#125;} gives {{localurl:a !}}. The main purpose was
The parser function <code>localurl:</code> replaces spaces by underscores and special characters by escape codes, e.g. {{localurl:a !}} gives {{localurl:a !}}. The main purpose was
to create a link to a given page in external link style in the same project or a project which uses the same string in the URL between the server name and the page name. This function is
to create a link to a given page in external link style in the same project or a project which uses the same string in the URL between the server name and the page name. This function is
now better served by less verbose <tt>fullurl:</tt> constructs, <code><nowiki>{{fullurl:page}}</nowiki></code> is a shorthand for <code><nowiki>{{SERVER}}{{localurl:page}}</nowiki></code>.
now better served by less verbose <code>fullurl:</code> constructs, <code><nowiki>{{fullurl:page}}</nowiki></code> is a shorthand for <code><nowiki>{{SERVER}}{{localurl:page}}</nowiki></code>.


Both <tt>fullurle:</tt> and <tt>localurle:</tt> performed additional character escaping on the resulting link, but no example is known where that still has any additional effect.
Both <code>fullurle:</code> and <code>localurle:</code> performed additional character escaping on the resulting link, but no example is known where that still has any additional effect.


Note that <tt>fullurl:</tt> and <tt>localurl:</tt> don't encode special characters and spaces in the optional ''query-string'' parameter. At least for spaces this will result in broken URLs:<br />
Note that <code>fullurl:</code> and <code>localurl:</code> don't encode special characters and spaces in the optional ''query-string'' parameter. At least for spaces this will result in broken URLs:<br />
<tt><nowiki>{{fullurl:m:Special:Contributions|target=Jimbo Wales&limit=10}}</nowiki></tt><br />
<code><nowiki>{{fullurl:m:Special:Contributions|target=Jimbo Wales&limit=10}}</nowiki></code><br />
{{fullurl:m:Special:Contributions|target=Jimbo Wales&limit=10}}
{{fullurl:m:Special:Contributions|target=Jimbo Wales&limit=10}}


With <tt><nowiki>target={{urlencode:Jimbo Wales}}&amp;limit=10</nowiki></tt> as ''query-string'' it works&#58;<br />
With <code><nowiki>target={{urlencode:Jimbo Wales}}&amp;limit=10</nowiki></code> as ''query-string'' it works:<br />
{{fullurl:m:Special:Contributions|target={{urlencode:Jimbo Wales}}&limit=10}}
{{fullurl:m:Special:Contributions|target={{urlencode:Jimbo Wales}}&limit=10}}


The new <tt>urlencode:</tt> encodes spaces as "'''<tt>+</tt>'''", not "'''<tt>_</tt>'''" or the generally supported "'''<tt>%20</tt>'''", this might have interesting effects, take care. Leading and trailing spaces are stripped, but all internal spaces are preserved:
The new <code>urlencode:</code> encodes spaces as "'''<code>+</code>'''", not "'''<code>_</code>'''" or the generally supported "'''<code>%20</code>'''", this might have interesting effects, take care. Leading and trailing spaces are stripped, but all internal spaces are preserved:
<tt><nowiki>{{urlencode:&nbsp;&#160;@&#160;&#160;!&nbsp;&#160;}}</nowiki></tt> yields '''{{urlencode: @ ! }}'''.
<code><nowiki>{{urlencode:&nbsp;&#160;@&#160;&#160;!&nbsp;&#160;}}</nowiki></code> yields '''{{urlencode: @ ! }}'''.
<!-- weird nbsp #160 mixture works with Netscape navigator 2.02 -->
<!-- weird nbsp #160 mixture works with Netscape navigator 2.02 -->
<!--
<!--
For obvious reasons encoding "'''<tt>&#125;}</tt>'''" or "'''<tt>|</tt>'''" cannot work directly. Don't encode "'''<tt>=</tt>'''", "'''<tt>&amp;</tt>'''", or "'''<tt>;</tt>'''" in structured ''query-strings'' unless you really want it.
For obvious reasons encoding "'''<code>}}</code>'''" or "'''<code>|</code>'''" cannot work directly. Don't encode "'''<code>=</code>'''", "'''<code>&amp;</code>'''", or "'''<code>;</code>'''" in structured ''query-strings'' unless you really want it.


===Example===
===Example===
Baris 264: Baris 264:
== LANGUAGE - bahasa ==
== LANGUAGE - bahasa ==
;atau Bahasa
;atau Bahasa
<code>{&#123;#language:''kode''&#125;}</code> menghasilkan nama bahasa lokal sesuai dengan kode RFC 3066 yang dimasukkan, jika tidak dikenali maka ditampilkan apa adanya. Untuk daftar lengkap lihat pula http://www.iana.org/assignments/language-subtag-registry IANA registry.
<code>{{#language:''kode''}}</code> menghasilkan nama bahasa lokal sesuai dengan kode RFC 3066 yang dimasukkan, jika tidak dikenali maka ditampilkan apa adanya. Untuk daftar lengkap lihat pula http://www.iana.org/assignments/language-subtag-registry IANA registry.
:{{nowiki|#language:|da}}
:{{nowiki|#language:|da}}
:{{nowiki|#language:|fo}}
:{{nowiki|#language:|fo}}
Baris 273: Baris 273:
:{{nowiki|#language:|frr}} (hilang, dimasukkan tahun 2006)
:{{nowiki|#language:|frr}} (hilang, dimasukkan tahun 2006)
:{{nowiki|#language:|mw}} (tidak ada kode bahasa ini di tahun 2006)
:{{nowiki|#language:|mw}} (tidak ada kode bahasa ini di tahun 2006)

Fungsi ini diharapkan akan menggantikan [[Special:Prefixindex/Template:Lang-|templat-templat berawalan 'lang-']]. <!-- For actually supported alpha2 and alpha3 codes see {{tim|sttnw}}, the 27*26*26 template calls may take some time. -->
Fungsi ini diharapkan akan menggantikan [[Special:Prefixindex/Template:Lang-|templat-templat berawalan 'lang-']]. <!-- For actually supported alpha2 and alpha3 codes see {{tim|sttnw}}, the 27*26*26 template calls may take some time. -->


== Halaman di kategori ==
== Halaman di kategori ==
{| class="wikitable"
{| class="wikitable"
! Kata
! Kata
! Contoh !! Contoh hasil
! Contoh !! Contoh hasil
|-
|-
| {&#123;<nowiki>PAGESINCATEGORY:category</nowiki>}}
| {{<nowiki>PAGESINCATEGORY:category</nowiki>}}
| {{nowiki3|PAGESINCATEGORY:|Rintisan umum}}
| {{nowiki3|PAGESINCATEGORY:|Rintisan umum}}
|-
|-
| {&#123;<nowiki>PAGESINCAT:category</nowiki>}}
| {{<nowiki>PAGESINCAT:category</nowiki>}}
| {{nowiki3|PAGESINCAT:|Rintisan umum}}
| {{nowiki3|PAGESINCAT:|Rintisan umum}}
|-
|-
| {&#123;<nowiki>PAGESINCATEGORY:category|R</nowiki>}}
| {{<nowiki>PAGESINCATEGORY:category|R</nowiki>}}
| {&#123;<code><nowiki>PAGESINCATEGORY:Rintisan umum|R</nowiki></code>}}||{{PAGESINCATEGORY:Rintisan umum|R}}
| {{<code><nowiki>PAGESINCATEGORY:Rintisan umum|R</nowiki></code>}}||{{PAGESINCATEGORY:Rintisan umum|R}}
|-
|-
| {&#123;<nowiki>PAGESINCAT:category|R</nowiki>}}
| {{<nowiki>PAGESINCAT:category|R</nowiki>}}
| {&#123;<code><nowiki>PAGESINCAT:Rintisan umum|R</nowiki></code>}}||{{PAGESINCATEGORY:Rintisan umum|R}}
| {{<code><nowiki>PAGESINCAT:Rintisan umum|R</nowiki></code>}}||{{PAGESINCATEGORY:Rintisan umum|R}}
|}
|}
'''[MW1.13+]''' Menampilkan jumlah halaman di dalam suatu kategori, termasuk jumlah subkategori dan berkas yang terkategorikan.
'''[MW1.13+]''' Menampilkan jumlah halaman di dalam suatu kategori, termasuk jumlah subkategori dan berkas yang terkategorikan.
Baris 336: Baris 336:


==Expansion==
==Expansion==
The first step in [[Help:Expansion|expanding]] any wikitext is identifying the templates, parser functions, variables and parameters from the braces, pipes and semicolons. For a parser function the next step is expanding the wikitext for the name of the parser function.
The first step in [[Help:Expansion|expanding]] any wikitext is identifying the templates, parser functions, variables and parameters from the braces, pipes and semicolons. For a parser function the next step is expanding the wikitext for the name of the parser function.


Suppose for example that it is #ifexpr. Then the next step is expanding the condition. Based on that either the wikitext for the then-part or that for the else-part is expanded.
Suppose for example that it is #ifexpr. Then the next step is expanding the condition. Based on that either the wikitext for the then-part or that for the else-part is expanded.


This is illustrated with <nowiki>{{#ifexpr:1|{{ta}}|{{tb}}}} {{#ifexpr:0|{{tc}}|{{td}}}}</nowiki> giving {{#ifexpr:1|{{ta}}|{{tb}}}} {{#ifexpr:0|{{tc}}|{{td}}}}. A page with this wikitext transcludes ta and td only (with the old preprocessor also tb and tc).
This is illustrated with <nowiki>{{#ifexpr:1|{{ta}}|{{tb}}}} {{#ifexpr:0|{{tc}}|{{td}}}}</nowiki> giving {{#ifexpr:1|{{ta}}|{{tb}}}} {{#ifexpr:0|{{tc}}|{{td}}}}. A page with this wikitext transcludes ta and td only (with the old preprocessor also tb and tc).




==Interpretation of a parser function as a template==
==Interpretation of a parser function as a template==
Baris 372: Baris 370:


==Terminology and history==
==Terminology and history==
Core parser functions were originally collectively unnamed in the MediaWiki codebase, although they were informally referred to simply as "functions" by developers. At some time around February 2006, editors of this documentation labelled them "colon functions", an unusual term which was unknown to the developers and the majority of users. In April 2006, the [[Help:ParserFunctions|ParserFunctions]] extension was introduced, along with a new extension interface allowing efficient addition of arbitrary numbers of these entities, now labelled "parser functions". The syntax for the new parser functions was modelled on that of the old core parser functions, the main difference being the addition of the leading hash "#".
Core parser functions were originally collectively unnamed in the MediaWiki codebase, although they were informally referred to simply as "functions" by developers. At some time around February 2006, editors of this documentation labelled them "colon functions", an unusual term which was unknown to the developers and the majority of users. In April 2006, the [[Help:ParserFunctions|ParserFunctions]] extension was introduced, along with a new extension interface allowing efficient addition of arbitrary numbers of these entities, now labelled "parser functions". The syntax for the new parser functions was modelled on that of the old core parser functions, the main difference being the addition of the leading hash "#".


In July 2006, the parser function interface was extended to allow old-style hashless functions, and the old core parser functions were converted from using special-case code to the new parser function interface. They were moved to a CoreParserFunctions module. Thus today, there is no difference at all in syntax or functionality between core parser functions and extension parser functions, besides the leading hash convention.
In July 2006, the parser function interface was extended to allow old-style hashless functions, and the old core parser functions were converted from using special-case code to the new parser function interface. They were moved to a CoreParserFunctions module. Thus today, there is no difference at all in syntax or functionality between core parser functions and extension parser functions, besides the leading hash convention.


Despite this, some users are in the habit of reserving the term "parser function" for members of the ParserFunctions extension. This is confusing and inaccurate -- any extension may define a parser function. The parser function interface has diverse applications. Perhaps it was confusing to call the extension ParserFunctions in the first place, but it was imagined as a fairly general repository of parser functions useful to Wikimedia.
Despite this, some users are in the habit of reserving the term "parser function" for members of the ParserFunctions extension. This is confusing and inaccurate -- any extension may define a parser function. The parser function interface has diverse applications. Perhaps it was confusing to call the extension ParserFunctions in the first place, but it was imagined as a fairly general repository of parser functions useful to Wikimedia.
Baris 394: Baris 392:
== Ekstensi ParserFunction ==
== Ekstensi ParserFunction ==
{{utama|Bantuan:ParserFunctions}}
{{utama|Bantuan:ParserFunctions}}
{{Navbox Gabungan Pedoman WBI}}

[[Kategori:Bantuan]]
[[Kategori:Bantuan Wikipedia]]

[[en:Help:Parser function]]
[[en:Help:Parser function]]

Revisi terkini sejak 26 Oktober 2023 15.25

 Seri Bantuan
Selamat datang! Halaman ini memberikan bantuan mengenai hal yang sering ditanyakan di Wikipedia. Untuk memulai, silakan mengeklik pranala yang Anda butuhkan di bawah ini, atau gunakan fitur pencari yang tersedia.

"Fungsi parser" (bahasa Inggris: parser function) (berbeda dengan ekstensi ParserFunctions yang merupakan kumpulan fungsi parser) adalah semacam templat yang memberikan nilai sesuai dengan paling sedikit satu parameter tak bernama, yang dipisahkan dari nama fungsi menggunakan tanda titik dua ":"; seperti templat biasa, fungsi ini mungkin memiliki beberapa parameter, masing-masing diawali dengan garis tegak "|". Sintaks dapat ditulis dengan atau tanpa tanda pagar "#" di awalnya:

{{namafungsi: argumen 1 | argumen 2 | argumen 3...}}

Untuk daftar kata-kata istimewa di Wikipedia, lihat pula Kata magis atau m:Help:Magic words (Inggris, lebih sering dimutakhirkan)

Untuk fungsi parser yang diawali tagar di depannya, sepert #expr:, #if:, #time, dsb, baca penggunaannya di Bantuan:ParserFunctions

Pemformatan

LC - huruf kecil

(LowerCase) atau huruf kecil.
Membuat teks menjadi huruf kecil dan menghilangkan karakter newline dan spasi di awal dan akhir teks.

{{lc:AbC dEf}} menghasilkan abc def.
{{lc:Ä Β Ç}} menghasilkan ä β ç, yang dikehendaki ä β ç.

UC - huruf besar

(UpperCase) atau huruf besar.
Membuat teks menjadi huruf besar dan menghilangkan karakter newline dan spasi di awal dan akhir teks.

{{uc:AbCdEf}} menghasilkan ABCDEF.
{{uc:ä β ß}} menghasilkan Ä Β SS, yang dikehendaki Ä Β SS.

LCFIRST - huruf pertama kecil

(LowerCaseFirst) atau huruf pertama huruf kecil.
Membuat huruf pertama teks menjadi huruf kecil dan menghilangkan karakter newline dan spasi di awal dan akhir teks.

{{lcfirst:Ab Cd}} menghasilkan ab Cd.

UCFIRST - huruf pertama besar

(UpperCaseFirst) atau huruf pertama huruf besar.
Membuat huruf pertama teks menjadi huruf besar dan menghilangkan karakter newline dan spasi di awal dan akhir teks.

{{ucfirst:aB cD}} menghasilkan AB cD.

URLENCODE

Menghilangkan karakter newline dan spasi di awal dan akhir teks, dan mengkonversi teks menjadi format yang ramah-URL

{{urlencode:halo dunia ?&=#/:}} menghasilkan halo+dunia+%3F%26%3D%23%2F%3A.

NB: Untuk pranala di dalam suatu halaman, gunakan {{anchorencode}}

ANCHORENCODE

Untuk pranala di dalam suatu halaman, gunakan {{anchorencode}}, bukan {{urlencode}}. Hasil dari penggunaan {{anchorencode}} kompatibel dengan referensi intra-halaman yang dihasilkan oleh [[#link|pranala]], sedangkan hasil dari penggunaan {{urlencode}} belum tentu demikian.

NS - ruang nama

(NameSpace) atau Ruang Nama.
Memberikan nama Ruang Nama
Kode
dengan Angka
Hasil
dengan Angka
Kode
dengan Nama
Hasil
dengan Nama
{{ns:-2}} Media {{ns:Media}} Media
{{ns:-1}} Istimewa {{ns:Special}} Istimewa
{{ns:0}} {{ns:0}}
{{ns:1}} Pembicaraan {{ns:Talk}} Pembicaraan
{{ns:2}} Pengguna {{ns:User}} Pengguna
{{ns:3}} Pembicaraan Pengguna {{ns:User_talk}} Pembicaraan Pengguna
{{ns:4}} Wikipedia {{ns:Project}} Wikipedia
{{ns:5}} Pembicaraan Wikipedia {{ns:Project_talk}} Pembicaraan Wikipedia
{{ns:6}} Berkas {{ns:Image}} Berkas
{{ns:7}} Pembicaraan Berkas {{ns:Image_talk}} Pembicaraan Berkas
{{ns:8}} MediaWiki {{ns:MediaWiki}} MediaWiki
{{ns:9}} Pembicaraan MediaWiki {{ns:MediaWiki_talk}} Pembicaraan MediaWiki
{{ns:10}} Templat {{ns:Template}} Templat
{{ns:11}} Pembicaraan Templat {{ns:Template_talk}} Pembicaraan Templat
{{ns:12}} Bantuan {{ns:Help}} Bantuan
{{ns:13}} Pembicaraan Bantuan {{ns:Help_talk}} Pembicaraan Bantuan
{{ns:14}} Kategori {{ns:Category}} Kategori
{{ns:15}} Pembicaraan Kategori {{ns:Category_talk}} Pembicaraan Kategori
Ruang Nama dengan nomor 100 ke atas dapat dikustomisasi di masing-masing situs wiki
{{ns:100}} Portal {{ns:Portal}} Portal
{{ns:101}} Pembicaraan Portal {{ns:Pembicaraan_Portal}} Pembicaraan Portal


URL - pranala

{{localurl:namahalaman}} /wiki/Namahalaman
{{localurl:halaman|query=x}} /w/index.php?title=Halaman&query=x
{{localurl:halaman|action=edit}} /w/index.php?title=Halaman&action=edit
{{localurl:a&b! c}} /wiki/A%26b!_c
{{localurle:a&b! c}} /wiki/A%26b!_c
{{urlencode:a&b! c}} a%26b%21+c
{{fullurl:namahalaman}} //wiki-indonesia.club/wiki/Namahalaman
{{fullurl:ab}} //wiki-indonesia.club/wiki/Ab
{{fullurl:a b}} //wiki-indonesia.club/wiki/A_b
{{fullurl:ab|u=v}} //wiki-indonesia.club/w/index.php?title=Ab&u=v
{{fullurl:a b|u=v}} //wiki-indonesia.club/w/index.php?title=A_b&u=v
{{fullurl:a b|u=v w}} //wiki-indonesia.club/w/index.php?title=A_b&u=v w
{{fullurl:a&b!|u=v}} //wiki-indonesia.club/w/index.php?title=A%26b!&u=v
{{fullurle:a&b!|u=v}} //wiki-indonesia.club/w/index.php?title=A%26b!&u=v
Dengan prefiks interwiki
{{fullurl:m:a b|u=v}} https://meta.wikimedia.org/wiki/a_b?u=v
{{fullurl:m:ab|u=v}} https://meta.wikimedia.org/wiki/ab?u=v

Perhatikan bahwa dengan prefiks interwiki, maka format "wiki/" digunakan meskipun untuk menyunting halaman dll.

For interwiki links localurl and fullurl give the same:

{{localurl:w:a}} https://en.wiki-indonesia.club/wiki/a
{{fullurl:w:a}} https://en.wiki-indonesia.club/wiki/a
Bagian ini belum diterjemahkan

The parser function localurl: replaces spaces by underscores and special characters by escape codes, e.g. /wiki/A_! gives /wiki/A_!. The main purpose was to create a link to a given page in external link style in the same project or a project which uses the same string in the URL between the server name and the page name. This function is now better served by less verbose fullurl: constructs, {{fullurl:page}} is a shorthand for {{SERVER}}{{localurl:page}}.

Both fullurle: and localurle: performed additional character escaping on the resulting link, but no example is known where that still has any additional effect.

Note that fullurl: and localurl: don't encode special characters and spaces in the optional query-string parameter. At least for spaces this will result in broken URLs:
{{fullurl:m:Special:Contributions|target=Jimbo Wales&limit=10}}
https://meta.wikimedia.org/wiki/Special:Contributions?target=Jimbo Wales&limit=10

With target={{urlencode:Jimbo Wales}}&limit=10 as query-string it works:
https://meta.wikimedia.org/wiki/Special:Contributions?target=Jimbo+Wales&limit=10

The new urlencode: encodes spaces as "+", not "_" or the generally supported "%20", this might have interesting effects, take care. Leading and trailing spaces are stripped, but all internal spaces are preserved: {{urlencode:  @  !  }} yields %40++%21.

Halaman di kategori

Kata Contoh Contoh hasil
{{PAGESINCATEGORY:category}} {{PAGESINCATEGORY:Rintisan umum}} 62
{{PAGESINCAT:category}} {{PAGESINCAT:Rintisan umum}} 62
{{PAGESINCATEGORY:category|R}} {{PAGESINCATEGORY:Rintisan umum|R}} 62
{{PAGESINCAT:category|R}} {{PAGESINCAT:Rintisan umum|R}} 62

[MW1.13+] Menampilkan jumlah halaman di dalam suatu kategori, termasuk jumlah subkategori dan berkas yang terkategorikan.


Ekstensi ParserFunction