-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(vrl): add casing functions (vectordotdev/vrl#973)
- Loading branch information
Showing
5 changed files
with
215 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,43 @@ | ||
package metadata | ||
|
||
remap: functions: camelcase: { | ||
category: "String" | ||
description: """ | ||
Takes the `value` string, and turns it into camelCase. Optionally, you can | ||
pass in the existing case of the function, or else we will try to figure out the case automatically. | ||
""" | ||
|
||
arguments: [ | ||
{ | ||
name: "value" | ||
description: "The string to convert to camelCase." | ||
required: true | ||
type: ["string"] | ||
}, | ||
{ | ||
name: "original_case" | ||
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case" | ||
required: false | ||
type: ["string"] | ||
}, | ||
] | ||
internal_failure_reasons: [] | ||
return: types: ["string"] | ||
|
||
examples: [ | ||
{ | ||
title: "camelCase a string" | ||
source: #""" | ||
camelcase("input-string") | ||
"""# | ||
return: "inputString" | ||
}, | ||
{ | ||
title: "camelCase a string" | ||
source: #""" | ||
camelcase("input-string", "kebab-case") | ||
"""# | ||
return: "inputString" | ||
}, | ||
] | ||
} |
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,43 @@ | ||
package metadata | ||
|
||
remap: functions: kebabcase: { | ||
category: "String" | ||
description: """ | ||
Takes the `value` string, and turns it into kebab-case. Optionally, you can | ||
pass in the existing case of the function, or else we will try to figure out the case automatically. | ||
""" | ||
|
||
arguments: [ | ||
{ | ||
name: "value" | ||
description: "The string to convert to kebab-case." | ||
required: true | ||
type: ["string"] | ||
}, | ||
{ | ||
name: "original_case" | ||
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case" | ||
required: false | ||
type: ["string"] | ||
}, | ||
] | ||
internal_failure_reasons: [] | ||
return: types: ["string"] | ||
|
||
examples: [ | ||
{ | ||
title: "kebab-case a string" | ||
source: #""" | ||
kebabcase("InputString") | ||
"""# | ||
return: "input-string" | ||
}, | ||
{ | ||
title: "kebab-case a string" | ||
source: #""" | ||
kebabcase("InputString", "PascalCase") | ||
"""# | ||
return: "input-string" | ||
}, | ||
] | ||
} |
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,43 @@ | ||
package metadata | ||
|
||
remap: functions: pascalcase: { | ||
category: "String" | ||
description: """ | ||
Takes the `value` string, and turns it into PascalCase. Optionally, you can | ||
pass in the existing case of the function, or else we will try to figure out the case automatically. | ||
""" | ||
|
||
arguments: [ | ||
{ | ||
name: "value" | ||
description: "The string to convert to PascalCase." | ||
required: true | ||
type: ["string"] | ||
}, | ||
{ | ||
name: "original_case" | ||
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case" | ||
required: false | ||
type: ["string"] | ||
}, | ||
] | ||
internal_failure_reasons: [] | ||
return: types: ["string"] | ||
|
||
examples: [ | ||
{ | ||
title: "PascalCase a string" | ||
source: #""" | ||
pascalcase("input-string") | ||
"""# | ||
return: "InputString" | ||
}, | ||
{ | ||
title: "PascalCase a string" | ||
source: #""" | ||
pascalcase("input-string", "kebab-case") | ||
"""# | ||
return: "InputString" | ||
}, | ||
] | ||
} |
43 changes: 43 additions & 0 deletions
43
website/cue/reference/remap/functions/screamingsnakecase.cue
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,43 @@ | ||
package metadata | ||
|
||
remap: functions: screamingsnakecase: { | ||
category: "String" | ||
description: """ | ||
Takes the `value` string, and turns it into SCREAMING_SNAKE case. Optionally, you can | ||
pass in the existing case of the function, or else we will try to figure out the case automatically. | ||
""" | ||
|
||
arguments: [ | ||
{ | ||
name: "value" | ||
description: "The string to convert to SCREAMING_SNAKE case." | ||
required: true | ||
type: ["string"] | ||
}, | ||
{ | ||
name: "original_case" | ||
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case" | ||
required: false | ||
type: ["string"] | ||
}, | ||
] | ||
internal_failure_reasons: [] | ||
return: types: ["string"] | ||
|
||
examples: [ | ||
{ | ||
title: "SCREAMING_SNAKE a string" | ||
source: #""" | ||
screamingsnakecase("input-string") | ||
"""# | ||
return: "INPUT_STRING" | ||
}, | ||
{ | ||
title: "SCREAMING_SNAKE a string" | ||
source: #""" | ||
screamingsnakecase("input-string", "kebab-case") | ||
"""# | ||
return: "INPUT_STRING" | ||
}, | ||
] | ||
} |
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,43 @@ | ||
package metadata | ||
|
||
remap: functions: snakecase: { | ||
category: "String" | ||
description: """ | ||
Takes the `value` string, and turns it into snake-case. Optionally, you can | ||
pass in the existing case of the function, or else we will try to figure out the case automatically. | ||
""" | ||
|
||
arguments: [ | ||
{ | ||
name: "value" | ||
description: "The string to convert to snake-case." | ||
required: true | ||
type: ["string"] | ||
}, | ||
{ | ||
name: "original_case" | ||
description: "Optional hint on the original case type. Must be one of: kebab-case, camelCase, PascalCase, SCREAMING_SNAKE, snake_case" | ||
required: false | ||
type: ["string"] | ||
}, | ||
] | ||
internal_failure_reasons: [] | ||
return: types: ["string"] | ||
|
||
examples: [ | ||
{ | ||
title: "snake-case a string" | ||
source: #""" | ||
snakecase("input-string") | ||
"""# | ||
return: "input_string" | ||
}, | ||
{ | ||
title: "snake-case a string" | ||
source: #""" | ||
snakecase("input-string", "kebab-case") | ||
"""# | ||
return: "input_string" | ||
}, | ||
] | ||
} |