From 9fcb8c258dad6ec14d69353e73a520792a39e394 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 1 Feb 2021 12:55:37 +0000 Subject: [PATCH] Converting markdown to HTML and rendering this for the hbs-helpers. --- .../PropertiesPanel/BindingPanel.svelte | 2 +- packages/string-templates/manifest.json | 248 +++++++++--------- packages/string-templates/package.json | 4 +- .../scripts/gen-collection-info.js | 18 +- packages/string-templates/yarn.lock | 7 +- 5 files changed, 147 insertions(+), 132 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte b/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte index ef74dee8c0..56bbc2d55b 100644 --- a/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte @@ -92,7 +92,7 @@
  • addToText(helper.text)}>
    - {helper.description} + {@html helper.description}
  • {/each} diff --git a/packages/string-templates/manifest.json b/packages/string-templates/manifest.json index ddee33e629..c23e3dc3a4 100644 --- a/packages/string-templates/manifest.json +++ b/packages/string-templates/manifest.json @@ -5,7 +5,7 @@ "a" ], "numArgs": 1, - "description": "Return the magnitude of `a`." + "description": "

    Return the magnitude of a.

    \n" }, "add": { "args": [ @@ -13,7 +13,7 @@ "b" ], "numArgs": 2, - "description": "Return the sum of `a` plus `b`." + "description": "

    Return the sum of a plus b.

    \n" }, "avg": { "args": [ @@ -21,14 +21,14 @@ ], "numArgs": 1, "example": "handlebars {{avg \"[1, 2, 3, 4, 5]\"}} ", - "description": "Returns the average of all numbers in the given array." + "description": "

    Returns the average of all numbers in the given array.

    \n" }, "ceil": { "args": [ "value" ], "numArgs": 1, - "description": "Get the `Math.ceil()` of the given value." + "description": "

    Get the Math.ceil() of the given value.

    \n" }, "divide": { "args": [ @@ -36,14 +36,14 @@ "b" ], "numArgs": 2, - "description": "Divide `a` by `b`" + "description": "

    Divide a by b

    \n" }, "floor": { "args": [ "value" ], "numArgs": 1, - "description": "Get the `Math.floor()` of the given value." + "description": "

    Get the Math.floor() of the given value.

    \n" }, "minus": { "args": [ @@ -51,7 +51,7 @@ "b" ], "numArgs": 2, - "description": "Return the product of `a` minus `b`." + "description": "

    Return the product of a minus b.

    \n" }, "modulo": { "args": [ @@ -59,7 +59,7 @@ "b" ], "numArgs": 2, - "description": "Get the remainder of a division operation." + "description": "

    Get the remainder of a division operation.

    \n" }, "multiply": { "args": [ @@ -67,7 +67,7 @@ "b" ], "numArgs": 2, - "description": "Return the product of `a` times `b`." + "description": "

    Return the product of a times b.

    \n" }, "plus": { "args": [ @@ -75,7 +75,7 @@ "b" ], "numArgs": 2, - "description": "Add `a` by `b`." + "description": "

    Add a by b.

    \n" }, "random": { "args": [ @@ -83,7 +83,7 @@ "max" ], "numArgs": 2, - "description": "Generate a random number between two values" + "description": "

    Generate a random number between two values

    \n" }, "remainder": { "args": [ @@ -91,14 +91,14 @@ "b" ], "numArgs": 2, - "description": "Get the remainder when `a` is divided by `b`." + "description": "

    Get the remainder when a is divided by b.

    \n" }, "round": { "args": [ "number" ], "numArgs": 1, - "description": "Round the given number." + "description": "

    Round the given number.

    \n" }, "subtract": { "args": [ @@ -106,7 +106,7 @@ "b" ], "numArgs": 2, - "description": "Return the product of `a` minus `b`." + "description": "

    Return the product of a minus b.

    \n" }, "sum": { "args": [ @@ -114,7 +114,7 @@ ], "numArgs": 1, "example": "handlebars {{sum \"[1, 2, 3, 4, 5]\"}} ", - "description": "Returns the sum of all numbers in the given array." + "description": "

    Returns the sum of all numbers in the given array.

    \n" }, "times": { "args": [ @@ -122,7 +122,7 @@ "b" ], "numArgs": 2, - "description": "Multiply number `a` by number `b`." + "description": "

    Multiply number a by number b.

    \n" } }, "array": { @@ -133,7 +133,7 @@ ], "numArgs": 2, "example": "handlebars {{after array 1}} ", - "description": "Returns all of the items in an array after the specified index. Opposite of [before](#before)." + "description": "

    Returns all of the items in an array after the specified index. Opposite of before.

    \n" }, "arrayify": { "args": [ @@ -141,7 +141,7 @@ ], "numArgs": 1, "example": "handlebars {{arrayify \"foo\"}} ", - "description": "Cast the given `value` to an array." + "description": "

    Cast the given value to an array.

    \n" }, "before": { "args": [ @@ -150,7 +150,7 @@ ], "numArgs": 2, "example": "handlebars {{before array 2}} ", - "description": "Return all of the items in the collection before the specified count. Opposite of [after](#after)." + "description": "

    Return all of the items in the collection before the specified count. Opposite of after.

    \n" }, "eachIndex": { "args": [ @@ -159,7 +159,7 @@ ], "numArgs": 2, "example": "handlebars {{#eachIndex array}} {{item}} is {{index}} {{/eachIndex}} ", - "description": "Iterates the array, listing an item and the index of it." + "description": "

    Iterates the array, listing an item and the index of it.

    \n" }, "filter": { "args": [ @@ -169,7 +169,7 @@ ], "numArgs": 3, "example": "handlebars {{#filter array \"foo\"}}AAA{{else}}BBB{{/filter}} ", - "description": "Block helper that filters the given array and renders the block for values that evaluate to `true`, otherwise the inverse block is returned." + "description": "

    Block helper that filters the given array and renders the block for values that evaluate to true, otherwise the inverse block is returned.

    \n" }, "first": { "args": [ @@ -178,7 +178,7 @@ ], "numArgs": 2, "example": "handlebars {{first \"['a', 'b', 'c', 'd', 'e']\" 2}} ", - "description": "Returns the first item, or first `n` items of an array." + "description": "

    Returns the first item, or first n items of an array.

    \n" }, "forEach": { "args": [ @@ -186,7 +186,7 @@ ], "numArgs": 1, "example": "handlebars {{#forEach accounts}} {{ name }} {{#unless isLast}}, {{/unless}} {{/forEach}} ", - "description": "Iterates over each item in an array and exposes the current item in the array as context to the inner block. In addition to the current array item, the helper exposes the following variables to the inner block: - `index` - `total` - `isFirst` - `isLast` Also, `@index` is exposed as a private variable, and additional private variables may be defined as hash arguments." + "description": "

    Iterates over each item in an array and exposes the current item in the array as context to the inner block. In addition to the current array item, the helper exposes the following variables to the inner block: - index - total - isFirst - isLast Also, @index is exposed as a private variable, and additional private variables may be defined as hash arguments.

    \n" }, "inArray": { "args": [ @@ -196,7 +196,7 @@ ], "numArgs": 3, "example": "handlebars {{#inArray array \"d\"}} foo {{else}} bar {{/inArray}} ", - "description": "Block helper that renders the block if an array has the given `value`. Optionally specify an inverse block to render when the array does not have the given value." + "description": "

    Block helper that renders the block if an array has the given value. Optionally specify an inverse block to render when the array does not have the given value.

    \n" }, "isArray": { "args": [ @@ -204,7 +204,7 @@ ], "numArgs": 1, "example": "handlebars {{isArray \"abc\"}} {{isArray array}} ", - "description": "Returns true if `value` is an es5 array." + "description": "

    Returns true if value is an es5 array.

    \n" }, "itemAt": { "args": [ @@ -213,7 +213,7 @@ ], "numArgs": 2, "example": "handlebars {{itemAt array 1}} ", - "description": "Returns the item from `array` at index `idx`." + "description": "

    Returns the item from array at index idx.

    \n" }, "join": { "args": [ @@ -222,7 +222,7 @@ ], "numArgs": 2, "example": "handlebars {{join array}} {{join array '-'}} ", - "description": "Join all elements of array into a string, optionally using a given separator." + "description": "

    Join all elements of array into a string, optionally using a given separator.

    \n" }, "equalsLength": { "args": [ @@ -231,7 +231,7 @@ "options" ], "numArgs": 3, - "description": "Returns true if the the length of the given `value` is equal to the given `length`. Can be used as a block or inline helper." + "description": "

    Returns true if the the length of the given value is equal to the given length. Can be used as a block or inline helper.

    \n" }, "last": { "args": [ @@ -240,7 +240,7 @@ ], "numArgs": 2, "example": "handlebars {{last value}} {{last value 2}} {{last value 3}} ", - "description": "Returns the last item, or last `n` items of an array or string. Opposite of [first](#first)." + "description": "

    Returns the last item, or last n items of an array or string. Opposite of first.

    \n" }, "length": { "args": [ @@ -248,7 +248,7 @@ ], "numArgs": 1, "example": "handlebars {{length '[\"a\", \"b\", \"c\"]'}} {{length myArray}} {{length myObject}} ", - "description": "Returns the length of the given string or array." + "description": "

    Returns the length of the given string or array.

    \n" }, "lengthEqual": { "args": [ @@ -257,7 +257,7 @@ "options" ], "numArgs": 3, - "description": "Returns true if the the length of the given `value` is equal to the given `length`. Can be used as a block or inline helper." + "description": "

    Returns true if the the length of the given value is equal to the given length. Can be used as a block or inline helper.

    \n" }, "map": { "args": [ @@ -266,7 +266,7 @@ ], "numArgs": 2, "example": "handlebars {{map array double}} ", - "description": "Returns a new array, created by calling `function` on each element of the given `array`. For example," + "description": "

    Returns a new array, created by calling function on each element of the given array. For example,

    \n" }, "pluck": { "args": [ @@ -275,7 +275,7 @@ ], "numArgs": 2, "example": "handlebars // {{pluck items \"data.title\"}} ", - "description": "Map over the given object or array or objects and create an array of values from the given `prop`. Dot-notation may be used (as a string) to get nested properties." + "description": "

    Map over the given object or array or objects and create an array of values from the given prop. Dot-notation may be used (as a string) to get nested properties.

    \n" }, "reverse": { "args": [ @@ -283,7 +283,7 @@ ], "numArgs": 1, "example": "handlebars {{reverse value}} {{reverse value}} ", - "description": "Reverse the elements in an array, or the characters in a string." + "description": "

    Reverse the elements in an array, or the characters in a string.

    \n" }, "some": { "args": [ @@ -293,7 +293,7 @@ ], "numArgs": 3, "example": "handlebars {{#some array isString}} Render me if the array has a string. {{else}} Render me if it doesn't. {{/some}} ", - "description": "Block helper that returns the block if the callback returns true for some value in the given array." + "description": "

    Block helper that returns the block if the callback returns true for some value in the given array.

    \n" }, "sort": { "args": [ @@ -302,7 +302,7 @@ ], "numArgs": 2, "example": "handlebars {{sort array}} ", - "description": "Sort the given `array`. If an array of objects is passed, you may optionally pass a `key` to sort on as the second argument. You may alternatively pass a sorting function as the second argument." + "description": "

    Sort the given array. If an array of objects is passed, you may optionally pass a key to sort on as the second argument. You may alternatively pass a sorting function as the second argument.

    \n" }, "sortBy": { "args": [ @@ -311,7 +311,7 @@ ], "numArgs": 2, "example": "handlebars {{sortBy array \"a\"}} ", - "description": "Sort an `array`. If an array of objects is passed, you may optionally pass a `key` to sort on as the second argument. You may alternatively pass a sorting function as the second argument." + "description": "

    Sort an array. If an array of objects is passed, you may optionally pass a key to sort on as the second argument. You may alternatively pass a sorting function as the second argument.

    \n" }, "withAfter": { "args": [ @@ -321,7 +321,7 @@ ], "numArgs": 3, "example": "handlebars {{#withAfter array 3}} {{this}} {{/withAfter}} ", - "description": "Use the items in the array _after_ the specified index as context inside a block. Opposite of [withBefore](#withBefore)." + "description": "

    Use the items in the array after the specified index as context inside a block. Opposite of withBefore.

    \n" }, "withBefore": { "args": [ @@ -331,7 +331,7 @@ ], "numArgs": 3, "example": "handlebars {{#withBefore array 3}} {{this}} {{/withBefore}} ", - "description": "Use the items in the array _before_ the specified index as context inside a block. Opposite of [withAfter](#withAfter)." + "description": "

    Use the items in the array before the specified index as context inside a block. Opposite of withAfter.

    \n" }, "withFirst": { "args": [ @@ -341,7 +341,7 @@ ], "numArgs": 3, "example": "handlebars {{#withFirst array}} {{this}} {{/withFirst}} ", - "description": "Use the first item in a collection inside a handlebars block expression. Opposite of [withLast](#withLast)." + "description": "

    Use the first item in a collection inside a handlebars block expression. Opposite of withLast.

    \n" }, "withGroup": { "args": [ @@ -351,7 +351,7 @@ ], "numArgs": 3, "example": "handlebars {{#withGroup array 4}} {{#each this}} {{.}} {{each}}
    {{/withGroup}} ", - "description": "Block helper that groups array elements by given group `size`." + "description": "

    Block helper that groups array elements by given group size.

    \n" }, "withLast": { "args": [ @@ -361,7 +361,7 @@ ], "numArgs": 3, "example": "handlebars {{#withLast array}} {{this}} {{/withLast}} ", - "description": "Use the last item or `n` items in an array as context inside a block. Opposite of [withFirst](#withFirst)." + "description": "

    Use the last item or n items in an array as context inside a block. Opposite of withFirst.

    \n" }, "withSort": { "args": [ @@ -371,7 +371,7 @@ ], "numArgs": 3, "example": "handlebars {{#withSort array}}{{this}}{{/withSort}} ", - "description": "Block helper that sorts a collection and exposes the sorted collection as context inside the block." + "description": "

    Block helper that sorts a collection and exposes the sorted collection as context inside the block.

    \n" }, "unique": { "args": [ @@ -380,7 +380,7 @@ ], "numArgs": 2, "example": "handlebars {{#each (unique array)}}{{.}}{{/each}} ", - "description": "Block helper that return an array with all duplicate values removed. Best used along with a [each](#each) helper." + "description": "

    Block helper that return an array with all duplicate values removed. Best used along with a each helper.

    \n" } }, "number": { @@ -389,21 +389,21 @@ "number" ], "numArgs": 1, - "description": "Format a number to it's equivalent in bytes. If a string is passed, it's length will be formatted and returned. **Examples:** - `'foo' => 3 B` - `13661855 => 13.66 MB` - `825399 => 825.39 kB` - `1396 => 1.4 kB`" + "description": "

    Format a number to it's equivalent in bytes. If a string is passed, it's length will be formatted and returned. Examples: - 'foo' => 3 B - 13661855 => 13.66 MB - 825399 => 825.39 kB - 1396 => 1.4 kB

    \n" }, "addCommas": { "args": [ "num" ], "numArgs": 1, - "description": "Add commas to numbers" + "description": "

    Add commas to numbers

    \n" }, "phoneNumber": { "args": [ "num" ], "numArgs": 1, - "description": "Convert a string or number to a formatted phone number." + "description": "

    Convert a string or number to a formatted phone number.

    \n" }, "toAbbr": { "args": [ @@ -411,7 +411,7 @@ "precision" ], "numArgs": 2, - "description": "Abbreviate numbers to the given number of `precision`. This for general numbers, not size in bytes." + "description": "

    Abbreviate numbers to the given number of precision. This for general numbers, not size in bytes.

    \n" }, "toExponential": { "args": [ @@ -420,7 +420,7 @@ ], "numArgs": 2, "example": "handlebars {{toExponential number digits}}; ", - "description": "Returns a string representing the given number in exponential notation." + "description": "

    Returns a string representing the given number in exponential notation.

    \n" }, "toFixed": { "args": [ @@ -429,21 +429,21 @@ ], "numArgs": 2, "example": "handlebars {{toFixed \"1.1234\" 2}} //=> '1.12' ", - "description": "Formats the given number using fixed-point notation." + "description": "

    Formats the given number using fixed-point notation.

    \n" }, "toFloat": { "args": [ "number" ], "numArgs": 1, - "description": "Convert input to a float." + "description": "

    Convert input to a float.

    \n" }, "toInt": { "args": [ "number" ], "numArgs": 1, - "description": "Convert input to an integer." + "description": "

    Convert input to an integer.

    \n" }, "toPrecision": { "args": [ @@ -452,7 +452,7 @@ ], "numArgs": 2, "example": "handlebars {{toPrecision \"1.1234\" 2}} //=> '1.1' ", - "description": "Returns a string representing the `Number` object to the specified precision." + "description": "

    Returns a string representing the Number object to the specified precision.

    \n" } }, "url": { @@ -461,31 +461,31 @@ "str" ], "numArgs": 1, - "description": "Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character." + "description": "

    Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.

    \n" }, "escape": { "args": [ "str" ], "numArgs": 1, - "description": "Escape the given string by replacing characters with escape sequences. Useful for allowing the string to be used in a URL, etc." + "description": "

    Escape the given string by replacing characters with escape sequences. Useful for allowing the string to be used in a URL, etc.

    \n" }, "decodeURI": { "args": [ "str" ], "numArgs": 1, - "description": "Decode a Uniform Resource Identifier (URI) component." + "description": "

    Decode a Uniform Resource Identifier (URI) component.

    \n" }, "url_encode": { "args": [], "numArgs": 0, - "description": "Alias for [encodeURI](#encodeuri)." + "description": "

    Alias for encodeURI.

    \n" }, "url_decode": { "args": [], "numArgs": 0, - "description": "Alias for [decodeURI](#decodeuri)." + "description": "

    Alias for decodeURI.

    \n" }, "urlResolve": { "args": [ @@ -493,21 +493,21 @@ "href" ], "numArgs": 2, - "description": "Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag." + "description": "

    Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag.

    \n" }, "urlParse": { "args": [ "str" ], "numArgs": 1, - "description": "Parses a `url` string into an object." + "description": "

    Parses a url string into an object.

    \n" }, "stripQuerystring": { "args": [ "url" ], "numArgs": 1, - "description": "Strip the query string from the given `url`." + "description": "

    Strip the query string from the given url.

    \n" }, "stripProtocol": { "args": [ @@ -515,7 +515,7 @@ ], "numArgs": 1, "example": "handlebars {{stripProtocol url}} ", - "description": "Strip protocol from a `url`. Useful for displaying media that may have an 'http' protocol on secure connections." + "description": "

    Strip protocol from a url. Useful for displaying media that may have an 'http' protocol on secure connections.

    \n" } }, "string": { @@ -526,7 +526,7 @@ ], "numArgs": 2, "example": "handlebars {{append item.stem \".html\"}} ", - "description": "Append the specified `suffix` to the given string." + "description": "

    Append the specified suffix to the given string.

    \n" }, "camelcase": { "args": [ @@ -534,7 +534,7 @@ ], "numArgs": 1, "example": "handlebars {{camelcase \"foo bar baz\"}}; ", - "description": "camelCase the characters in the given `string`." + "description": "

    camelCase the characters in the given string.

    \n" }, "capitalize": { "args": [ @@ -542,7 +542,7 @@ ], "numArgs": 1, "example": "handlebars {{capitalize \"foo bar baz\"}} ", - "description": "Capitalize the first word in a sentence." + "description": "

    Capitalize the first word in a sentence.

    \n" }, "capitalizeAll": { "args": [ @@ -550,7 +550,7 @@ ], "numArgs": 1, "example": "handlebars {{capitalizeAll \"foo bar baz\"}} ", - "description": "Capitalize all words in a string." + "description": "

    Capitalize all words in a string.

    \n" }, "center": { "args": [ @@ -558,7 +558,7 @@ "spaces" ], "numArgs": 2, - "description": "Center a string using non-breaking spaces" + "description": "

    Center a string using non-breaking spaces

    \n" }, "chop": { "args": [ @@ -566,7 +566,7 @@ ], "numArgs": 1, "example": "handlebars {{chop \"_ABC_\"}} {{chop \"-ABC-\"}} {{chop \" ABC \"}} ", - "description": "Like trim, but removes both extraneous whitespace **and non-word characters** from the beginning and end of a string." + "description": "

    Like trim, but removes both extraneous whitespace and non-word characters from the beginning and end of a string.

    \n" }, "dashcase": { "args": [ @@ -574,7 +574,7 @@ ], "numArgs": 1, "example": "handlebars {{dashcase \"a-b-c d_e\"}} ", - "description": "dash-case the characters in `string`. Replaces non-word characters and periods with hyphens." + "description": "

    dash-case the characters in string. Replaces non-word characters and periods with hyphens.

    \n" }, "dotcase": { "args": [ @@ -582,7 +582,7 @@ ], "numArgs": 1, "example": "handlebars {{dotcase \"a-b-c d_e\"}} ", - "description": "dot.case the characters in `string`." + "description": "

    dot.case the characters in string.

    \n" }, "downcase": { "args": [ @@ -590,7 +590,7 @@ ], "numArgs": 1, "example": "handlebars {{downcase \"aBcDeF\"}} ", - "description": "Lowercase all of the characters in the given string. Alias for [lowercase](#lowercase)." + "description": "

    Lowercase all of the characters in the given string. Alias for lowercase.

    \n" }, "ellipsis": { "args": [ @@ -599,7 +599,7 @@ ], "numArgs": 2, "example": "handlebars {{ellipsis (sanitize \"foo bar baz\"), 7}} {{ellipsis \"foo bar baz\", 7}} ", - "description": "Truncates a string to the specified `length`, and appends it with an elipsis, `…`." + "description": "

    Truncates a string to the specified length, and appends it with an elipsis, .

    \n" }, "hyphenate": { "args": [ @@ -607,7 +607,7 @@ ], "numArgs": 1, "example": "handlebars {{hyphenate \"foo bar baz qux\"}} ", - "description": "Replace spaces in a string with hyphens." + "description": "

    Replace spaces in a string with hyphens.

    \n" }, "isString": { "args": [ @@ -615,7 +615,7 @@ ], "numArgs": 1, "example": "handlebars {{isString \"foo\"}} ", - "description": "Return true if `value` is a string." + "description": "

    Return true if value is a string.

    \n" }, "lowercase": { "args": [ @@ -623,7 +623,7 @@ ], "numArgs": 1, "example": "handlebars {{lowercase \"Foo BAR baZ\"}} ", - "description": "Lowercase all characters in the given string." + "description": "

    Lowercase all characters in the given string.

    \n" }, "occurrences": { "args": [ @@ -632,7 +632,7 @@ ], "numArgs": 2, "example": "handlebars {{occurrences \"foo bar foo bar baz\" \"foo\"}} ", - "description": "Return the number of occurrences of `substring` within the given `string`." + "description": "

    Return the number of occurrences of substring within the given string.

    \n" }, "pascalcase": { "args": [ @@ -640,7 +640,7 @@ ], "numArgs": 1, "example": "handlebars {{pascalcase \"foo bar baz\"}} ", - "description": "PascalCase the characters in `string`." + "description": "

    PascalCase the characters in string.

    \n" }, "pathcase": { "args": [ @@ -648,7 +648,7 @@ ], "numArgs": 1, "example": "handlebars {{pathcase \"a-b-c d_e\"}} ", - "description": "path/case the characters in `string`." + "description": "

    path/case the characters in string.

    \n" }, "plusify": { "args": [ @@ -656,7 +656,7 @@ ], "numArgs": 1, "example": "handlebars {{plusify \"foo bar baz\"}} ", - "description": "Replace spaces in the given string with pluses." + "description": "

    Replace spaces in the given string with pluses.

    \n" }, "prepend": { "args": [ @@ -665,7 +665,7 @@ ], "numArgs": 2, "example": "handlebars {{prepend val \"foo-\"}} ", - "description": "Prepends the given `string` with the specified `prefix`." + "description": "

    Prepends the given string with the specified prefix.

    \n" }, "raw": { "args": [ @@ -673,7 +673,7 @@ ], "numArgs": 1, "example": "handlebars {{{{#raw}}}} {{foo}} {{{{/raw}}}} ", - "description": "Render a block without processing mustache templates inside the block." + "description": "

    Render a block without processing mustache templates inside the block.

    \n" }, "remove": { "args": [ @@ -682,7 +682,7 @@ ], "numArgs": 2, "example": "handlebars {{remove \"a b a b a b\" \"a \"}} ", - "description": "Remove all occurrences of `substring` from the given `str`." + "description": "

    Remove all occurrences of substring from the given str.

    \n" }, "removeFirst": { "args": [ @@ -691,7 +691,7 @@ ], "numArgs": 2, "example": "handlebars {{remove \"a b a b a b\" \"a\"}} ", - "description": "Remove the first occurrence of `substring` from the given `str`." + "description": "

    Remove the first occurrence of substring from the given str.

    \n" }, "replace": { "args": [ @@ -701,7 +701,7 @@ ], "numArgs": 3, "example": "handlebars {{replace \"a b a b a b\" \"a\" \"z\"}} ", - "description": "Replace all occurrences of substring `a` with substring `b`." + "description": "

    Replace all occurrences of substring a with substring b.

    \n" }, "replaceFirst": { "args": [ @@ -711,7 +711,7 @@ ], "numArgs": 3, "example": "handlebars {{replace \"a b a b a b\" \"a\" \"z\"}} ", - "description": "Replace the first occurrence of substring `a` with substring `b`." + "description": "

    Replace the first occurrence of substring a with substring b.

    \n" }, "sentence": { "args": [ @@ -719,7 +719,7 @@ ], "numArgs": 1, "example": "handlebars {{sentence \"hello world. goodbye world.\"}} ", - "description": "Sentence case the given string" + "description": "

    Sentence case the given string

    \n" }, "snakecase": { "args": [ @@ -727,7 +727,7 @@ ], "numArgs": 1, "example": "handlebars {{snakecase \"a-b-c d_e\"}} ", - "description": "snake_case the characters in the given `string`." + "description": "

    snake_case the characters in the given string.

    \n" }, "split": { "args": [ @@ -735,7 +735,7 @@ ], "numArgs": 1, "example": "handlebars {{split \"a,b,c\" \",\"}} ", - "description": "Split `string` by the given `character`." + "description": "

    Split string by the given character.

    \n" }, "startsWith": { "args": [ @@ -745,7 +745,7 @@ ], "numArgs": 3, "example": "handlebars {{#startsWith \"Goodbye\" \"Hello, world!\"}} Whoops {{else}} Bro, do you even hello world? {{/startsWith}} ", - "description": "Tests whether a string begins with the given prefix." + "description": "

    Tests whether a string begins with the given prefix.

    \n" }, "titleize": { "args": [ @@ -753,7 +753,7 @@ ], "numArgs": 1, "example": "handlebars {{titleize \"this title case\"}} ", - "description": "Title case the given string." + "description": "

    Title case the given string.

    \n" }, "trim": { "args": [ @@ -761,7 +761,7 @@ ], "numArgs": 1, "example": "handlebars {{trim \" ABC \"}} ", - "description": "Removes extraneous whitespace from the beginning and end of a string." + "description": "

    Removes extraneous whitespace from the beginning and end of a string.

    \n" }, "trimLeft": { "args": [ @@ -769,7 +769,7 @@ ], "numArgs": 1, "example": "handlebars {{trim \" ABC \"}} ", - "description": "Removes extraneous whitespace from the beginning of a string." + "description": "

    Removes extraneous whitespace from the beginning of a string.

    \n" }, "trimRight": { "args": [ @@ -777,7 +777,7 @@ ], "numArgs": 1, "example": "handlebars {{trimRight \" ABC \"}} ", - "description": "Removes extraneous whitespace from the end of a string." + "description": "

    Removes extraneous whitespace from the end of a string.

    \n" }, "truncate": { "args": [ @@ -787,7 +787,7 @@ ], "numArgs": 3, "example": "handlebars truncate(\"foo bar baz\", 7); truncate(sanitize(\"foo bar baz\", 7)); ", - "description": "Truncate a string to the specified `length`. Also see [ellipsis](#ellipsis)." + "description": "

    Truncate a string to the specified length. Also see ellipsis.

    \n" }, "truncateWords": { "args": [ @@ -797,7 +797,7 @@ ], "numArgs": 3, "example": "handlebars truncateWords(\"foo bar baz\", 1); truncateWords(\"foo bar baz\", 2); truncateWords(\"foo bar baz\", 3); ", - "description": "Truncate a string to have the specified number of words. Also see [truncate](#truncate)." + "description": "

    Truncate a string to have the specified number of words. Also see truncate.

    \n" }, "upcase": { "args": [ @@ -805,7 +805,7 @@ ], "numArgs": 1, "example": "handlebars {{upcase \"aBcDeF\"}} ", - "description": "Uppercase all of the characters in the given string. Alias for [uppercase](#uppercase)." + "description": "

    Uppercase all of the characters in the given string. Alias for uppercase.

    \n" }, "uppercase": { "args": [ @@ -814,7 +814,7 @@ ], "numArgs": 2, "example": "handlebars {{uppercase \"aBcDeF\"}} ", - "description": "Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks." + "description": "

    Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks.

    \n" } }, "comparison": { @@ -826,7 +826,7 @@ ], "numArgs": 3, "example": "handlebars {{#and great magnificent}}A{{else}}B{{/and}} ", - "description": "Helper that renders the block if **both** of the given values are truthy. If an inverse block is specified it will be rendered when falsy. Works as a block helper, inline helper or subexpression." + "description": "

    Helper that renders the block if both of the given values are truthy. If an inverse block is specified it will be rendered when falsy. Works as a block helper, inline helper or subexpression.

    \n" }, "compare": { "args": [ @@ -836,7 +836,7 @@ "options" ], "numArgs": 4, - "description": "Render a block when a comparison of the first and third arguments returns true. The second argument is the [arithemetic operator][operators] to use. You may also optionally specify an inverse block to render when falsy." + "description": "

    Render a block when a comparison of the first and third arguments returns true. The second argument is the [arithemetic operator][operators] to use. You may also optionally specify an inverse block to render when falsy.

    \n" }, "contains": { "args": [ @@ -847,7 +847,7 @@ ], "numArgs": 4, "example": "handlebars {{#contains array \"d\"}} This will not be rendered. {{else}} This will be rendered. {{/contains}} ", - "description": "Block helper that renders the block if `collection` has the given `value`, using strict equality (`===`) for comparison, otherwise the inverse block is rendered (if specified). If a `startIndex` is specified and is negative, it is used as the offset from the end of the collection." + "description": "

    Block helper that renders the block if collection has the given value, using strict equality (===) for comparison, otherwise the inverse block is rendered (if specified). If a startIndex is specified and is negative, it is used as the offset from the end of the collection.

    \n" }, "default": { "args": [ @@ -855,7 +855,7 @@ "defaultValue" ], "numArgs": 2, - "description": "Returns the first value that is not undefined, otherwise the \"default\" value is returned." + "description": "

    Returns the first value that is not undefined, otherwise the "default" value is returned.

    \n" }, "eq": { "args": [ @@ -864,7 +864,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if `a` is **equal to** `b`. If an inverse block is specified it will be rendered when falsy. You may optionally use the `compare=\"\"` hash argument for the second value." + "description": "

    Block helper that renders a block if a is equal to b. If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.

    \n" }, "gt": { "args": [ @@ -873,7 +873,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if `a` is **greater than** `b`. If an inverse block is specified it will be rendered when falsy. You may optionally use the `compare=\"\"` hash argument for the second value." + "description": "

    Block helper that renders a block if a is greater than b. If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.

    \n" }, "gte": { "args": [ @@ -882,7 +882,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if `a` is **greater than or equal to** `b`. If an inverse block is specified it will be rendered when falsy. You may optionally use the `compare=\"\"` hash argument for the second value." + "description": "

    Block helper that renders a block if a is greater than or equal to b. If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.

    \n" }, "has": { "args": [ @@ -891,7 +891,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if `value` has `pattern`. If an inverse block is specified it will be rendered when falsy." + "description": "

    Block helper that renders a block if value has pattern. If an inverse block is specified it will be rendered when falsy.

    \n" }, "isFalsey": { "args": [ @@ -899,7 +899,7 @@ "options" ], "numArgs": 2, - "description": "Returns true if the given `value` is falsey. Uses the [falsey][] library for comparisons. Please see that library for more information or to report bugs with this helper." + "description": "

    Returns true if the given value is falsey. Uses the [falsey][] library for comparisons. Please see that library for more information or to report bugs with this helper.

    \n" }, "isTruthy": { "args": [ @@ -907,7 +907,7 @@ "options" ], "numArgs": 2, - "description": "Returns true if the given `value` is truthy. Uses the [falsey][] library for comparisons. Please see that library for more information or to report bugs with this helper." + "description": "

    Returns true if the given value is truthy. Uses the [falsey][] library for comparisons. Please see that library for more information or to report bugs with this helper.

    \n" }, "ifEven": { "args": [ @@ -916,7 +916,7 @@ ], "numArgs": 2, "example": "handlebars {{#ifEven value}} render A {{else}} render B {{/ifEven}} ", - "description": "Return true if the given value is an even number." + "description": "

    Return true if the given value is an even number.

    \n" }, "ifNth": { "args": [ @@ -925,7 +925,7 @@ "options" ], "numArgs": 3, - "description": "Conditionally renders a block if the remainder is zero when `a` operand is divided by `b`. If an inverse block is specified it will be rendered when the remainder is **not zero**." + "description": "

    Conditionally renders a block if the remainder is zero when a operand is divided by b. If an inverse block is specified it will be rendered when the remainder is not zero.

    \n" }, "ifOdd": { "args": [ @@ -934,7 +934,7 @@ ], "numArgs": 2, "example": "handlebars {{#ifOdd value}} render A {{else}} render B {{/ifOdd}} ", - "description": "Block helper that renders a block if `value` is **an odd number**. If an inverse block is specified it will be rendered when falsy." + "description": "

    Block helper that renders a block if value is an odd number. If an inverse block is specified it will be rendered when falsy.

    \n" }, "is": { "args": [ @@ -943,7 +943,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if `a` is **equal to** `b`. If an inverse block is specified it will be rendered when falsy. Similar to [eq](#eq) but does not do strict equality." + "description": "

    Block helper that renders a block if a is equal to b. If an inverse block is specified it will be rendered when falsy. Similar to eq but does not do strict equality.

    \n" }, "isnt": { "args": [ @@ -952,7 +952,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if `a` is **not equal to** `b`. If an inverse block is specified it will be rendered when falsy. Similar to [unlessEq](#unlesseq) but does not use strict equality for comparisons." + "description": "

    Block helper that renders a block if a is not equal to b. If an inverse block is specified it will be rendered when falsy. Similar to unlessEq but does not use strict equality for comparisons.

    \n" }, "lt": { "args": [ @@ -960,7 +960,7 @@ "options" ], "numArgs": 2, - "description": "Block helper that renders a block if `a` is **less than** `b`. If an inverse block is specified it will be rendered when falsy. You may optionally use the `compare=\"\"` hash argument for the second value." + "description": "

    Block helper that renders a block if a is less than b. If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.

    \n" }, "lte": { "args": [ @@ -969,7 +969,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if `a` is **less than or equal to** `b`. If an inverse block is specified it will be rendered when falsy. You may optionally use the `compare=\"\"` hash argument for the second value." + "description": "

    Block helper that renders a block if a is less than or equal to b. If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.

    \n" }, "neither": { "args": [ @@ -978,7 +978,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that renders a block if **neither of** the given values are truthy. If an inverse block is specified it will be rendered when falsy." + "description": "

    Block helper that renders a block if neither of the given values are truthy. If an inverse block is specified it will be rendered when falsy.

    \n" }, "not": { "args": [ @@ -986,7 +986,7 @@ "options" ], "numArgs": 2, - "description": "Returns true if `val` is falsey. Works as a block or inline helper." + "description": "

    Returns true if val is falsey. Works as a block or inline helper.

    \n" }, "or": { "args": [ @@ -995,7 +995,7 @@ ], "numArgs": 2, "example": "handlebars {{#or a b c}} If any value is true this will be rendered. {{/or}} ", - "description": "Block helper that renders a block if **any of** the given values is truthy. If an inverse block is specified it will be rendered when falsy." + "description": "

    Block helper that renders a block if any of the given values is truthy. If an inverse block is specified it will be rendered when falsy.

    \n" }, "unlessEq": { "args": [ @@ -1004,7 +1004,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that always renders the inverse block **unless `a` is equal to `b`**." + "description": "

    Block helper that always renders the inverse block unless a is equal to b.

    \n" }, "unlessGt": { "args": [ @@ -1013,7 +1013,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that always renders the inverse block **unless `a` is greater than `b`**." + "description": "

    Block helper that always renders the inverse block unless a is greater than b.

    \n" }, "unlessLt": { "args": [ @@ -1022,7 +1022,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that always renders the inverse block **unless `a` is less than `b`**." + "description": "

    Block helper that always renders the inverse block unless a is less than b.

    \n" }, "unlessGteq": { "args": [ @@ -1031,7 +1031,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that always renders the inverse block **unless `a` is greater than or equal to `b`**." + "description": "

    Block helper that always renders the inverse block unless a is greater than or equal to b.

    \n" }, "unlessLteq": { "args": [ @@ -1040,7 +1040,7 @@ "options" ], "numArgs": 3, - "description": "Block helper that always renders the inverse block **unless `a` is less than or equal to `b`**." + "description": "

    Block helper that always renders the inverse block unless a is less than or equal to b.

    \n" } }, "date": { @@ -1050,8 +1050,8 @@ "format" ], "numArgs": 2, - "example": "{{date \"5 years ago\" \"YYYY\"}}", - "description": "Format a date using moment.js data formatting." + "example": "{{date now \"YYYY\"}}", + "description": "

    Format a date using moment.js data formatting.

    \n" } } } \ No newline at end of file diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 0ce825c9c0..1ebaab1d08 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -10,7 +10,8 @@ "scripts": { "build": "tsc && rollup -c", "dev:builder": "tsc && rollup -cw", - "test": "jest" + "test": "jest", + "manifest": "node ./scripts/gen-collection-info.js" }, "dependencies": { "@budibase/handlebars-helpers": "^0.11.1", @@ -24,6 +25,7 @@ "@rollup/plugin-json": "^4.1.0", "doctrine": "^3.0.0", "jest": "^26.6.3", + "marked": "^1.2.8", "rollup": "^2.36.2", "rollup-plugin-node-builtins": "^2.1.2", "rollup-plugin-node-globals": "^1.4.0", diff --git a/packages/string-templates/scripts/gen-collection-info.js b/packages/string-templates/scripts/gen-collection-info.js index 82ac843e36..d7e464a8ae 100644 --- a/packages/string-templates/scripts/gen-collection-info.js +++ b/packages/string-templates/scripts/gen-collection-info.js @@ -1,9 +1,13 @@ -const helpers = require("handlebars-helpers") +const HELPER_LIBRARY = "@budibase/handlebars-helpers" +const helpers = require(HELPER_LIBRARY) const { HelperFunctionBuiltin } = require("../src/helpers/constants") const fs = require("fs") const doctrine = require("doctrine") +const marked = require("marked") -const FILENAME = "../manifest.json" +const DIRECTORY = fs.existsSync("node_modules") ? "." : ".." + +const FILENAME = `${DIRECTORY}/manifest.json` /** * full list of supported helpers can be found here: @@ -29,8 +33,6 @@ function fixSpecialCases(name, obj) { if (name === "toInt") { obj.description = "Convert input to an integer." } - // add the date helper - obj return obj } @@ -91,7 +93,7 @@ function run() { const foundNames = [] for (let collection of COLLECTIONS) { const collectionFile = fs.readFileSync( - `../node_modules/handlebars-helpers/lib/${collection}.js`, + `${DIRECTORY}/node_modules/${HELPER_LIBRARY}/lib/${collection}.js`, "utf8" ) const collectionInfo = {} @@ -138,6 +140,12 @@ function run() { description: "Format a date using moment.js data formatting.", }, } + // convert all markdown to HTML + for (let collection of Object.values(outputJSON)) { + for (let helper of Object.values(collection)) { + helper.description = marked(helper.description) + } + } fs.writeFileSync(FILENAME, JSON.stringify(outputJSON, null, 2)) } diff --git a/packages/string-templates/yarn.lock b/packages/string-templates/yarn.lock index 9cb3dc1fd4..96ff364e51 100644 --- a/packages/string-templates/yarn.lock +++ b/packages/string-templates/yarn.lock @@ -270,7 +270,7 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/handlebars-helpers@^0.11.0": +"@budibase/handlebars-helpers@^0.11.1": version "0.11.1" resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.11.1.tgz#fe8672612fb4ad8fd3bad338ee15759f45e421eb" integrity sha512-s72LhOhlHk43QYGVcqjogaGa4h4e6y6X1AfshqWBWceTRYBs/9tUnoYDUiRJ/Mt3WoTmx8Hj5GOZekSqrUsOFQ== @@ -3419,6 +3419,11 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +marked@^1.2.8: + version "1.2.8" + resolved "https://registry.yarnpkg.com/marked/-/marked-1.2.8.tgz#5008ece15cfa43e653e85845f3525af4beb6bdd4" + integrity sha512-lzmFjGnzWHkmbk85q/ILZjFoHHJIQGF+SxGEfIdGk/XhiTPhqGs37gbru6Kkd48diJnEyYwnG67nru0Z2gQtuQ== + md5.js@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"