Skip to content

Including content

Inline strings get unwieldy fast. The include() helper loads content from disk or a URL so your slide bodies stay short.

From a local file

fun includeFromFile() {
  kslides {
    presentation {
      markdownSlide {
        content {
          include("src/main/resources/slides/intro.md")
        }
      }
    }
  }
}

Paths are resolved relative to the working directory of the running program.

From a URL

fun includeFromUrl() {
  kslides {
    presentation {
      markdownSlide {
        content {
          include("https://raw.githubusercontent.com/kslides/kslides/master/README.md")
        }
      }
    }
  }
}

Useful for pulling READMEs or shared snippets without copy-pasting.

With code snippets

include() plays well with codeSnippet { } — see Code snippets:

fun codeSnippetFromUrl() {
  kslides {
    presentation {
      dslSlide {
        content {
          codeSnippet {
            language = "kotlin"
            highlightPattern = "1|3-5"
            code = include(
              "https://raw.githubusercontent.com/kslides/kslides/master/kslides-examples/src/main/kotlin/playground/HelloWorld.kt",
            )
          }
        }
      }
    }
  }
}

Best practices

  • Keep slide bodies in source-controlled files (src/main/resources/slides/...) so reviewers can diff them.
  • Use URL includes for content owned by other repos to avoid duplication, but be mindful of network availability at build time.