forked from platformsh/platformsh-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request platformsh#3401 from platformsh/version-shortcodes
Add versioning shortcodes
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 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,10 @@ | ||
<!-- Markdown passed between shortcode `vendor/inner` will render only if the current version = first passed variable --> | ||
<!-- For example, --> | ||
<!-- vendor/only "1" --> | ||
<!-- platform variable:get --> | ||
<!-- /vendor/only --> | ||
<!-- When the site is built, the `platform` command will appear iff vendor.config.version = 1 in params.yaml --> | ||
{{- $version := .Site.Params.vendor.config.version -}} | ||
{{- if eq $version ( int (.Get 0)) -}} | ||
{{- .Inner | .Page.RenderString -}} | ||
{{- end -}} |
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,18 @@ | ||
<!-- Markdown processes 2 versions, rendering only if key matches current version --> | ||
<!-- Key 1: Version 1; the first Inner prior to the dividing character --> | ||
<!-- Key 2: Version 2; the second Inner after the dividing character --> | ||
<!-- For example, --> | ||
<!-- vendor/specific --> | ||
<!-- platform variable:get --> | ||
<!-- (divider: see $splitVersionChar below) --> | ||
<!-- friday variable:get --> | ||
<!-- /vendor/specific --> | ||
{{- $page := .Page -}} | ||
{{- $version := .Site.Params.vendor.config.version -}} | ||
{{- $splitVersionChar := "<--->" -}} | ||
{{- range $k, $v := split .Inner $splitVersionChar -}} | ||
{{- $current := add $k 1 -}} | ||
{{- if eq $current $version -}} | ||
{{- $v | $page.RenderString -}} | ||
{{- end -}} | ||
{{- end -}} |