From f74e93a84ab47f6e060ff124211adb38c7c8112f Mon Sep 17 00:00:00 2001 From: Joshua Barton Date: Thu, 30 Jun 2022 18:12:44 -0500 Subject: [PATCH] docs: add documentation for starts and endswith --- website/data/language-nav-data.json | 8 +++++ website/docs/language/functions/endswith.mdx | 30 +++++++++++++++++++ .../docs/language/functions/startswith.mdx | 30 +++++++++++++++++++ website/layouts/language.erb | 8 +++++ 4 files changed, 76 insertions(+) create mode 100644 website/docs/language/functions/endswith.mdx create mode 100644 website/docs/language/functions/startswith.mdx diff --git a/website/data/language-nav-data.json b/website/data/language-nav-data.json index a0ec64131e4e..9fdc4ece605c 100644 --- a/website/data/language-nav-data.json +++ b/website/data/language-nav-data.json @@ -319,6 +319,10 @@ "title": "chomp", "href": "/language/functions/chomp" }, + { + "title": "endswith", + "href": "/language/functions/endswith" + }, { "title": "format", "href": "/language/functions/format" @@ -352,6 +356,10 @@ "title": "split", "href": "/language/functions/split" }, + { + "title": "startswith", + "href": "/language/functions/startswith" + }, { "title": "strrev", "href": "/language/functions/strrev" diff --git a/website/docs/language/functions/endswith.mdx b/website/docs/language/functions/endswith.mdx new file mode 100644 index 000000000000..8599f3582b7a --- /dev/null +++ b/website/docs/language/functions/endswith.mdx @@ -0,0 +1,30 @@ +--- +page_title: endswith - Functions - Configuration Language +description: |- + The endswith function takes a given string and a given suffix value, + and returns true if the first given string contains the given value at its end. +--- + +# `endswith` Function + +`endswith` takes a given string and a given suffix value, +and returns true if the first given string contains the given value at its end. + +```hcl +endswith(string, suffix) +``` + +## Examples + +``` +> endswith("hello world", "world") +true + +> endswith("hello world", "hello") +false +``` + +## Related Functions + +- [`startswith`](/language/functions/startswith) takes a given string and a given prefix value, + and returns true if the first given string contains the given value at its beginning diff --git a/website/docs/language/functions/startswith.mdx b/website/docs/language/functions/startswith.mdx new file mode 100644 index 000000000000..02295beade3c --- /dev/null +++ b/website/docs/language/functions/startswith.mdx @@ -0,0 +1,30 @@ +--- +page_title: startsswith - Functions - Configuration Language +description: |- + The startswith function takes a given string and a given prefix value, + and returns true if the first given string contains the given value at its beginning. +--- + +# `startswith` Function + +`startswith` takes a given string and a given prefix value, +and returns true if the first given string contains the given value at its beginning. + +```hcl +startswith(string, prefix) +``` + +## Examples + +``` +> startswith("hello world", "hello") +true + +> startswith("hello world", "world") +false +``` + +## Related Functions + +- [`endswith`](/language/functions/endswith) takes a given string and a given suffix value, + and returns true if the first given string contains the given value at its end \ No newline at end of file diff --git a/website/layouts/language.erb b/website/layouts/language.erb index 7f7e55e7f3df..f2bf83dede52 100644 --- a/website/layouts/language.erb +++ b/website/layouts/language.erb @@ -370,6 +370,10 @@ chomp +
  • + endswith +
  • +
  • format
  • @@ -406,6 +410,10 @@ split +
  • + startswith +
  • +
  • strrev