-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This shortcode allows inserting the content of a file into another to reuse content. Changes: - Support for relative paths - Support for a single positional parameter - Documentation added
- Loading branch information
Showing
5 changed files
with
161 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{/* Handle the "file" named parameter or a single unnamed parameter as the file | ||
path */}} | ||
{{ if .IsNamedParams }} | ||
{{ $.Scratch.Set "fparameter" ( .Get "file" ) }} | ||
{{ else }} | ||
{{ $.Scratch.Set "fparameter" ( .Get 0 ) }} | ||
{{ end }} | ||
|
||
|
||
{{/* If the first character is "/", the path is absolute from the site's | ||
`baseURL`. Otherwise, construct an absolute path using the current directory */}} | ||
|
||
{{ if eq (.Scratch.Get "fparameter" | printf "%.1s") "/" }} | ||
{{ $.Scratch.Set "filepath" ($.Scratch.Get "fparameter") }} | ||
{{ else }} | ||
{{ $.Scratch.Set "filepath" "/" }} | ||
{{ $.Scratch.Add "filepath" $.Page.File.Dir }} | ||
{{ $.Scratch.Add "filepath" ($.Scratch.Get "fparameter") }} | ||
{{ end }} | ||
|
||
|
||
{{/* If the file exists, read it and highlight it if it's code. Throw an error | ||
if the file is not found */}} | ||
|
||
{{ if fileExists ($.Scratch.Get "filepath") }} | ||
{{ if eq (.Get "code") "true" }} | ||
{{- highlight ($.Scratch.Get "filepath" | readFile | htmlUnescape | | ||
safeHTML ) (.Get "lang") "" -}} | ||
{{ else }} | ||
{{- $.Scratch.Get "filepath" | readFile | htmlUnescape | safeHTML -}} | ||
{{ end }} | ||
{{ else }} | ||
|
||
<p style="color: #D74848"><b><i>The file <code>{{ $.Scratch.Get "filepath" }}</code> was not found.</i></b></p> | ||
|
||
{{ end }} |
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
userguide/content/en/docs/Adding content/Shortcodes/includes/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: hello | ||
spec: | ||
steps: | ||
- name: echo | ||
image: alpine | ||
script: | | ||
#!/bin/sh | ||
echo "Hello World" |
10 changes: 10 additions & 0 deletions
10
userguide/content/en/docs/Adding content/Shortcodes/includes/installation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**Installation** | ||
|
||
1. Download the installation files. | ||
|
||
1. Run the installation script | ||
|
||
`sudo sh install.sh` | ||
|
||
1. Test that your installation was successfully completed. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters