Categories
Tutorial, Manual, Tips dan Trik

How to Write a Customizable Post

Have you ever imagined writing an article or tutorial that allows some sections to be adapted according to the conditions of the reader? The purpose of this is to have fun with readers, to liven up tutorials and for other purposes

Apakah Anda pernah membayangkan menulis sebuah artikel atau tutorial yang mengijinkan beberapa bagian dapat disesuaikan sesuai dengan kondisi pembaca? Hal ini dilakukan untuk bersenang-senang dengan pembaca, membuat tutorial menjadi hidup dan untuk tujuan lainnya.

Daftar Isi

Write a Customizable Post

Usually, you write https://example.org in your tutorials. But actually you can create a textbox so readers can write the address on their own and the address written in the tutorial will adjust accordingly.
Biasanya, Anda menulis https://example.org di tutorial Anda. Namun sebenarnya Anda bisa membuat textbox agar pembaca bisa menulis alamatnya sendiri dan alamat yang tertulis di tutorial akan menyesuaikan.

— How to Write a Customizable Post
https://bptsi.unisayogya.ac.id/how-to-write-a-customizable-post/ 2023-02-02 17:03:56

Prerequisite / Prasyarat

Install plugin current post.

Syntax / Format Penggunaan

Rule

  1. variable name regex: a-zA-Z_
    example:
    this_isVARiable
  2. output:
    • function call (unescape dot),
      example:
      Math.round(x/y)
    • operator,
      example:
      x+y
      x+' '+y
    • simple if then else ?:,
      example:
      x==y?(x==z?x:z):y
    • string (maybe need escape with \),
      example:
      "abc" or \"abc\"
      'abc' or \'abc\'
    • assignment: use variable input with formula,
      example:
      [currentpost type="variableinput" label="x|||formula:y+z"]
    • no loop, no error handling
  3. character replacement:
    > replace with >, example: x>y?x:y;
    < replace with &lt;, example: x&lt;y?x:y;
    . replace with \. (dot with \ escape), example: x\.y;

Call

  1. “variableinput”: create textbox as an input of variable,
    • input with initial value,
      label: "variable_name|||initial value"
    • input as assignment,
      label: "variable_name|||formula:theformula"
  2. “variableoutput”: create a span to display variable’s value,
    • output without enclose,
      label: "variable_name"
    • output with enclose,
      label: “variable_name|||enclose”
      example:
      "x|||'" result: 'abc'
      "y|||[" result: [xyz]

Aturan

  1. nama variabel menggunakan regex: a-zA-Z_
    contoh:
    ini_adalahVARiabel
  2. luaran:
    • pemanggilan fungsi (titik tanpa escape),
      contoh:
      Math.round(x/y)
    • operator,
      contoh:
      x+y
      x+' '+y
    • if then else ?: sederhana,
      contoh:
      x==y?(x==z?x:z):y
    • string (mungkin membutuhkan escape \),
      contoh:
      "abc" atau \"abc\"
      'abc' atau \'abc\'
    • penugasan: gunakan variable input dengan formula,
      contoh:
      [currentpost type="variableinput" label="x|||formula:y+z"]
    • tidak mendukung loop dan error handling
  3. penggantian karakter:
    > diganti dengan &gt;, contoh: x&gt;y?x:y;
    < diganti dengan &lt;, contoh: x&lt;y?x:y;
    . diganti dengan \. (dot with \ escape), contoh: x\.y;

Pemanggilan

  1. “variableinput”: membuat textbox sebagai masukan dari variabel,
    • input dengan nilai awal,
      label: "nama_variabel|||nilai awal"
    • input as assignment,
      `label: “nama_variabel|||formula:theformula”`
  2. “variableoutput”: membuat sebuah span untuk menampilkan nilai dari suatu variabel,
    • luaran tanpa enclose,
      label: "nama_variabel"
    • luaran dengan enclose,
      label: "nama_variabel|||enclose"
      contoh:
      "x|||'" result: 'abc'
      "y|||[" result: [xyz]

Implementation / Implementasi

Design

Type your name [currentpost type="variableinput" label="name|||John"]
Type your hair [currentpost type="variableinput" label="hair|||curly"]
Type your brother(s) [currentpost type="variableinput" label="bro|||1"]
Type your sister(s) [currentpost type="variableinput" label="sis|||2"]
Relatives [currentpost type="variableinput" label="relatives|||formula:bro+sis"]

Hai, my name is [currentpost type="variableoutput" label="name"]. My hair is [currentpost type="variableoutput" label="hair"]. How about you? Nice to meet you, I’m [currentpost type="variableoutput" label="name"]. I have [currentpost type="variableoutput" label="bro+sis"] relatives, yes [currentpost type="variableoutput" label="relatives"], [currentpost type="variableoutput" label="bro+' brother(s) and '+sis+' sister(s)'"]. The number of my brothers is [currentpost type="variableoutput" label="bro==sis?'equal to':(bro&gt;sis?\'more than\':\'less than\')"] my sisters.

I will tell you that round from [currentpost type="variableoutput" label="bro"] divided by [currentpost type="variableoutput" label="sis"] is [currentpost type="variableoutput" label="Math.round(bro/sis)"].

Result

Type your name
Type your hair
Type your brother(s)
Type your sister(s)
Relatives

Hai, my name is . My hair is . How about you? Nice to meet you, I’m . I have relatives, yes , . The number of my brothers is my sisters.

I will tell you that round from divided by is .

Desain

Ketik nama Anda [currentpost type="variableinput" label="nama|||Johan"]
Ketik jenis rambut Anda [currentpost type="variableinput" label="rambut|||berombak"]
Ketik saudaramu [currentpost type="variableinput" label="sdr|||1"]
Ketik saudarimu [currentpost type="variableinput" label="sdri|||2"]
Kerabat [currentpost type="variableinput" label="kerabat|||formula:sdr+sdri"]

Hai, nama saya [currentpost type="variableoutput" label="nama"]. Rambut saya [currentpost type="variableoutput" label="rambut"]. Bagaimana dengan Anda? Senang berjumpa dengan Anda, saya, [currentpost type="variableoutput" label="nama"]. Saya memiliki [currentpost type="variableoutput" label="sdr+sdri"] kerabat, ya [currentpost type="variableoutput" label="kerabat"], [currentpost type="variableoutput" label="sdr+' saudara dan '+sdri+' saudari'"]. Jumlah saudara saya [currentpost type="variableoutput" label="sdr==sdri?'sama dengan':(sdr&gt;sdri?\'lebih dari\':\'kurang dari\')"] saudari saya.

Saya akan memberitahu Anda bahwa pembulatan dari [currentpost type="variableoutput" label="sdr"] dibagi dengan [currentpost type="variableoutput" label="sdri"] adalah [currentpost type="variableoutput" label="Math.round(sdr/sdri)"].

Hasil

Ketik nama Anda
Ketik jenis rambut Anda
Ketik saudaramu
Ketik saudarimu
Kerabat

Hai, nama saya . Rambut saya . Bagaimana dengan Anda? Senang berjumpa dengan Anda, saya, . Saya memiliki kerabat, ya , . Jumlah saudara saya saudari saya.

Saya akan memberitahu Anda bahwa pembulatan dari dibagi dengan adalah .

That’s it. [bst]

By basit

Biro Pengembangan Teknologi Dan Sistem Informasi

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.