🏠

DSL 投影片 🐦

用 DSL 語法撰寫投影片

什麼是 DSL

領域特定語言

用 Kotlin 定義的語法

在特定領域做特定的事情

什麼是 DSL

              dslSlide {
    content {
        h2 { +"什麼是 DSL" }
        b { +"領域特定語言" }
        p { +"用 Kotlin 定義的語法" }
        p { +"在特定領域做特定的事情" }
    }
}
            

包含程式碼區塊的 dslSlide


fun main() {
  for (i in (0..5)) {
    println("Hello World $i")
  }
}

            

投影片程式碼寫法


dslSlide {
    val src = "kslides-examples/src/main/kotlin/content/HelloWorldK.kt"
    val url = githubRawUrl("kslides", "kslides", src)
    content {
        h2 { +"包含程式碼區塊的 dslSlide" }
        // Display lines 3-7 of the url content and highlight lines 1 and 5, 2 and 4, and finally 3
        codeSnippet {
            language = "kotlin"
            highlightPattern = "[1,5|2,4|3]"
            +include(url, "[3-7]")
        }
    }
}

            

加上動畫


{
  "id":"555",
  "language":"C++",
  "author":"Bjarne Stroustrup"
}

            

加上動畫


{
  "id":"444",
  "language":"C",
  "author":"Dennis Ritchie"
},
{
  "id":"555",
  "language":"C++",
  "author":"Bjarne Stroustrup"
}

            

加上動畫


"books":[
  {
    "id":"444",
    "language":"C",
    "author":"Dennis Ritchie"
  },
  {
    "id":"555",
    "language":"C++",
    "author":"Bjarne Stroustrup"
  }
]

            

加上動畫


{
  "books":[
    {
      "id":"444",
      "language":"C",
      "author":"Dennis Ritchie"
    },
    {
      "id":"555",
      "language":"C++",
      "author":"Bjarne Stroustrup"
    }
  ]
}

            

動畫和行數


{
  "id":"555",
  "language":"C++",
  "author":"Bjarne Stroustrup"
}

            

動畫和行數


{
  "id":"444",
  "language":"C",
  "author":"Dennis Ritchie"
},
{
  "id":"555",
  "language":"C++",
  "author":"Bjarne Stroustrup"
}

            

動畫和行數


"books":[
  {
    "id":"444",
    "language":"C",
    "author":"Dennis Ritchie"
  },
  {
    "id":"555",
    "language":"C++",
    "author":"Bjarne Stroustrup"
  }
]

            

動畫和行數


{
  "books":[
    {
      "id":"444",
      "language":"C",
      "author":"Dennis Ritchie"
    },
    {
      "id":"555",
      "language":"C++",
      "author":"Bjarne Stroustrup"
    }
  ]
}