Skip to content

Commit cbe384f

Browse files
Add include-code shortcode (#502)
1 parent 4f47ebf commit cbe384f

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

doc/content/example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def foo(x):
2+
return x**2
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{/*
2+
3+
doc: Include a file with syntax highlighting.
4+
5+
{{< include-code "example.py" "python" >}}
6+
7+
*/}}
8+
9+
{{ $filename := (path.Join .Page.File.Dir (.Get 0)) }}
10+
{{- highlight (readFile $filename) (.Get 1) -}}

0 commit comments

Comments
 (0)