From a7baf2fcfd8232c02147c47348136c59af81a3e2 Mon Sep 17 00:00:00 2001 From: Joseph J Guerra <8146030+josephjguerra@users.noreply.github.com> Date: Wed, 29 May 2019 11:57:23 -0400 Subject: [PATCH 1/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e31b325..ca73c30 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,6 @@ I, {{author}}, author of the blog post "{{title}}", certify that I am the origin ## Important -See LICENSE for copyright and license terms. Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the software or any related documentation, whether expressed or implied, including but not limited to the warranties or merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, service or other resource is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate. +See LICENSE for copyright and license terms. Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any related applications. We make no representation, warranty, guarantee or undertaking in respect of the software or any related documentation, whether expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall we be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or documentation or the use or other dealings in the software or documentation. Any test results or performance figures are indicative and will not reflect performance under all conditions. Any reference to any third party or third-party product, service or other resource is not an endorsement or recommendation by Block.one. We are not responsible, and disclaim any and all responsibility and liability, for your use of or reliance on any of these resources. Third-party resources may be updated, changed or terminated at any time, so the information here may be out of date or inaccurate. Any person using or offering this software in connection with providing software, goods or services to third parties shall advise such third parties of these license terms, disclaimers and exclusions of liability. Block.one, EOSIO, EOSIO Labs, EOS, the heptahedron and associated logos are trademarks of Block.one. Wallets and related components are complex software that require the highest levels of security. If incorrectly built or used, they may compromise users’ private keys and digital assets. Wallet applications and related components should undergo thorough security evaluations before being used. Only experienced developers should work with this software. From d294ba30b5ddf423cd50c13fc12c8747d26bb5ee Mon Sep 17 00:00:00 2001 From: Eddie Sheffield Date: Wed, 5 Jun 2019 15:39:20 -0400 Subject: [PATCH 2/7] Update Ricardian spec to version 0.2 Mainly adds a section defining the available helpers and which version of the spec they became available in. --- README.md | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ca73c30..4bdce0b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## EOSIO.CDT Ricardian Contract Specification ![EOSIO Alpha](https://img.shields.io/badge/EOSIO-Alpha-blue.svg) -**Spec Version**: v0.1.1 +**Spec Version**: v0.2.0 ### General Information In conjunction with [Ricardian Template Toolkit](https://github.com/EOSIO/ricardian-template-toolkit/), this specification is a new addition to the [EOSIO.CDT](https://github.com/EOSIO/eosio.cdt) suite of tooling. @@ -83,9 +83,9 @@ For styling purposes, by default interpolated variables in the output will be wr * Action values will be given the `action` class (e.g., `
value
`) * Clause values will be given the `clauses` class (e.g., `
value
`) -In cases where this default variable wrapping can cause problems (e.g. a variable containing a URL that becomes the value of an HREF attribute) there are additional Handlebars handlers to override the default behavior. +In cases where this default variable wrapping can cause problems (e.g. a variable containing a URL that becomes the value of an HREF attribute) there are additional Handlebars helpers to override the default behavior. -* To prevent an individual variable from being wrapped, use the `nowrap` handler. +* To prevent an individual variable from being wrapped, use the `nowrap` helper. For example, to create a link with unwrapped individual variables: @@ -97,6 +97,41 @@ In cases where this default variable wrapping can cause problems (e.g. a variabl `{{#wrap}}[{{nowrap link.text}}]({{nowrap link.url}}){{/wrap}}` +#### Handlebars helpers + +In addition to the standard helpers which are part of Handlebars, there are a number of additional helpers defined to assist with Ricardian contract specific issues. + +___Since 0.0___ +* `wrap` - Takes no parameters. Block level helper to wrap the contents with `
` tags for highlighting. See `Variables` section above for more details. + +* `nowrap` - Takes a variable. Indicates that the specified variable *should not* be wrapped with `
` tags. See `Variables` section above for more details. + +* `symbol_to_symbol_code` - Given a variable containing a 'symbol' string, extract and return only the symbol code. For example: '4,EOS' --> returns 'EOS'. + +* `asset_to_symbol_code` - Given a variable containing an 'asset' string, extract and return only the symbol code. For example: '2.001 EOS' --> returns 'EOS'. + +___Since 0.1___ +* `account_in_permission_level` - Given a variable containing a permission level object, extract and return the account name. + +* `permission_in_permission_level` - Given a variable containing a permission level object, extract and return the account name. + +* `amount_from_asset` - Given a variable containing an asset, extract and return the amount. + +* `symbol_name_from_asset` - Given a variable containing an asset, extract and return the symbol name. + +___Since 0.2___ +* `to_json` - Takes the given variable and renders it as a preformatted JSON string. Note that the resulting string is also surrounded by `
` tags as well. This is intended as a debugging aid.
+
+* `if_has_value` - A block level helper which checks the given variable and if it is defined __AND__ not null then renders the content. If the variable is `undefined` __OR__ null render nothing or the contents of the `{{ else }}` clause if specified.
+
+  Example:
+  ```
+  {{#if_has_value myVar}}
+    Render if myVar has a non-null value
+  {{ else }}
+    Render if myVar is undefined or null
+  {{/if_has_value}}
+  ```
 #### HTML in variables
 
 By default, any `{{variables}}` that contain HTML will have that HTML escaped. This may not be the desired outcome, as the `ricardian_clauses` may have HTML that the author wants rendered rather than escaped.

From ad4a02e4fb123e6298c648dbad0524758c40cd83 Mon Sep 17 00:00:00 2001
From: Eddie Sheffield 
Date: Wed, 5 Jun 2019 17:38:38 -0400
Subject: [PATCH 3/7] Added / updated examples for helpers

---
 README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 62 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 4bdce0b..422d96a 100644
--- a/README.md
+++ b/README.md
@@ -106,18 +106,70 @@ ___Since 0.0___
 
 * `nowrap` - Takes a variable. Indicates that the specified variable *should not* be wrapped with `
` tags. See `Variables` section above for more details. -* `symbol_to_symbol_code` - Given a variable containing a 'symbol' string, extract and return only the symbol code. For example: '4,EOS' --> returns 'EOS'. +* `symbol_to_symbol_code` - Given a variable containing a 'symbol' string, extract and return only the symbol code. -* `asset_to_symbol_code` - Given a variable containing an 'asset' string, extract and return only the symbol code. For example: '2.001 EOS' --> returns 'EOS'. + Example: + ``` + Given: + symbol = '4,EOS' + + {{ symbol_to_symbol_code symbol }} --> 'EOS'. + +* `asset_to_symbol_code` - Given a variable containing an 'asset' string, extract and return only the symbol code. + + Example: + ``` + Given: + asset = '2.001 EOS' + + {{ asset_to_symbol_code asset }} --> 'EOS'. ___Since 0.1___ * `account_in_permission_level` - Given a variable containing a permission level object, extract and return the account name. -* `permission_in_permission_level` - Given a variable containing a permission level object, extract and return the account name. + Example: + ``` + Given Permission level / authorization: + auth = { + "actor": "alicejones", + "permission": "active" + } + + In Ricardian contract: + {{ account_in_permission_level auth }} --> 'alicejones' + ``` + +* `permission_in_permission_level` - Given a variable containing a permission level object, extract and return the permission name. + + Example: + ``` + Given Permission level / authorization: + auth = { + actor: 'alicejones', + permission: 'active' + } + + In Ricardian contract: + {{ permission_in_permission_level auth }} --> 'active' + ``` * `amount_from_asset` - Given a variable containing an asset, extract and return the amount. -* `symbol_name_from_asset` - Given a variable containing an asset, extract and return the symbol name. + Example: + ``` + Given: + asset = '2.001 EOS' + + {{ amount_from_asset asset }} --> '2.001'. + +* `symbol_name_from_asset` - Given a variable containing an asset, extract and return the symbol name. For example: '2.001 EOS' --> returns 'EOS'. + + Example: + ``` + Given: + asset = '2.001 EOS' + + {{ symbol_name_from_asset asset }} --> 'EOS'. ___Since 0.2___ * `to_json` - Takes the given variable and renders it as a preformatted JSON string. Note that the resulting string is also surrounded by `
` tags as well. This is intended as a debugging aid.
@@ -126,6 +178,12 @@ ___Since 0.2___
 
   Example:
   ```
+  {{#if_has_value myVar}}
+    Render if myVar has a non-null value
+  {{/if_has_value}}
+
+  Or
+  
   {{#if_has_value myVar}}
     Render if myVar has a non-null value
   {{ else }}

From e94f197ba6d2bc103db0e7a6244acaa25d7a5d00 Mon Sep 17 00:00:00 2001
From: Eddie Sheffield 
Date: Fri, 7 Jun 2019 10:49:54 -0400
Subject: [PATCH 4/7] Updating from review comments

---
 README.md | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 422d96a..a7dc731 100644
--- a/README.md
+++ b/README.md
@@ -101,10 +101,10 @@ In cases where this default variable wrapping can cause problems (e.g. a variabl
 
 In addition to the standard helpers which are part of Handlebars, there are a number of additional helpers defined to assist with Ricardian contract specific issues.
 
-___Since 0.0___
-* `wrap` - Takes no parameters. Block level helper to wrap the contents with `
` tags for highlighting. See `Variables` section above for more details. +___Since v0.0___ +* `wrap` - Takes no parameters. Block level helper to wrap the contents with `
` tags for highlighting. See [Variables](#Variables) section above for more details. -* `nowrap` - Takes a variable. Indicates that the specified variable *should not* be wrapped with `
` tags. See `Variables` section above for more details. +* `nowrap` - Takes a variable. Indicates that the specified variable *should not* be wrapped with `
` tags. See [Variables](#Variables) section above for more details. * `symbol_to_symbol_code` - Given a variable containing a 'symbol' string, extract and return only the symbol code. @@ -123,8 +123,9 @@ ___Since 0.0___ asset = '2.001 EOS' {{ asset_to_symbol_code asset }} --> 'EOS'. + ``` -___Since 0.1___ +___Since v0.1___ * `account_in_permission_level` - Given a variable containing a permission level object, extract and return the account name. Example: @@ -161,8 +162,9 @@ ___Since 0.1___ asset = '2.001 EOS' {{ amount_from_asset asset }} --> '2.001'. + ``` -* `symbol_name_from_asset` - Given a variable containing an asset, extract and return the symbol name. For example: '2.001 EOS' --> returns 'EOS'. +* `symbol_name_from_asset` - Given a variable containing an asset, extract and return the symbol name. Example: ``` @@ -170,10 +172,23 @@ ___Since 0.1___ asset = '2.001 EOS' {{ symbol_name_from_asset asset }} --> 'EOS'. + ``` -___Since 0.2___ +___Since v0.2___ * `to_json` - Takes the given variable and renders it as a preformatted JSON string. Note that the resulting string is also surrounded by `
` tags as well. This is intended as a debugging aid.
 
+  Example:
+  ```
+  {{to_json nameObj}}
+
+  

+  {
+    "firstname": "John",
+    "lastname": "Doe"
+  }
+  
+ ``` + * `if_has_value` - A block level helper which checks the given variable and if it is defined __AND__ not null then renders the content. If the variable is `undefined` __OR__ null render nothing or the contents of the `{{ else }}` clause if specified. Example: From a1df6ec719d61425998235bc76e41c8cf07ae0e4 Mon Sep 17 00:00:00 2001 From: Eddie Sheffield Date: Fri, 7 Jun 2019 11:15:36 -0400 Subject: [PATCH 5/7] Missed one --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a7dc731..503a986 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ ___Since v0.0___ symbol = '4,EOS' {{ symbol_to_symbol_code symbol }} --> 'EOS'. + ``` * `asset_to_symbol_code` - Given a variable containing an 'asset' string, extract and return only the symbol code. From 9999a4c548201b95a4a281fb60e0e599e3da7bb4 Mon Sep 17 00:00:00 2001 From: Eddie Sheffield Date: Fri, 7 Jun 2019 17:23:39 -0400 Subject: [PATCH 6/7] Marked redundant helpers as deprecated. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 503a986..2f4bb5c 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ ___Since v0.0___ ``` ___Since v0.1___ -* `account_in_permission_level` - Given a variable containing a permission level object, extract and return the account name. +* `account_in_permission_level` - _(__Deprecated__ Unnecessary since the account name can be accessed directly on the authorization object via standard dot notation.)_ Given a variable containing a permission level object, extract and return the account name. Example: ``` @@ -141,7 +141,7 @@ ___Since v0.1___ {{ account_in_permission_level auth }} --> 'alicejones' ``` -* `permission_in_permission_level` - Given a variable containing a permission level object, extract and return the permission name. +* `permission_in_permission_level` - _(__Deprecated__ Unnecessary since the permission name can be accessed directly on the authorization object via standard dot notation.)_ Given a variable containing a permission level object, extract and return the permission name. Example: ``` @@ -165,7 +165,7 @@ ___Since v0.1___ {{ amount_from_asset asset }} --> '2.001'. ``` -* `symbol_name_from_asset` - Given a variable containing an asset, extract and return the symbol name. +* `symbol_name_from_asset` - _(__Deprecated__ Use `asset_to_symbol_code` instead.)_ Given a variable containing an asset, extract and return the symbol name. Example: ``` From 02962b0326b5ceb5774d35c54c3f1149555e076c Mon Sep 17 00:00:00 2001 From: Eddie Sheffield Date: Mon, 10 Jun 2019 10:39:54 -0400 Subject: [PATCH 7/7] Removed deprecated helpers entirely. Other cleanups. --- README.md | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 2f4bb5c..989ed3d 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ In cases where this default variable wrapping can cause problems (e.g. a variabl `{{#wrap}}[{{nowrap link.text}}]({{nowrap link.url}}){{/wrap}}` -#### Handlebars helpers +#### Handlebars Helpers In addition to the standard helpers which are part of Handlebars, there are a number of additional helpers defined to assist with Ricardian contract specific issues. @@ -127,34 +127,6 @@ ___Since v0.0___ ``` ___Since v0.1___ -* `account_in_permission_level` - _(__Deprecated__ Unnecessary since the account name can be accessed directly on the authorization object via standard dot notation.)_ Given a variable containing a permission level object, extract and return the account name. - - Example: - ``` - Given Permission level / authorization: - auth = { - "actor": "alicejones", - "permission": "active" - } - - In Ricardian contract: - {{ account_in_permission_level auth }} --> 'alicejones' - ``` - -* `permission_in_permission_level` - _(__Deprecated__ Unnecessary since the permission name can be accessed directly on the authorization object via standard dot notation.)_ Given a variable containing a permission level object, extract and return the permission name. - - Example: - ``` - Given Permission level / authorization: - auth = { - actor: 'alicejones', - permission: 'active' - } - - In Ricardian contract: - {{ permission_in_permission_level auth }} --> 'active' - ``` - * `amount_from_asset` - Given a variable containing an asset, extract and return the amount. Example: @@ -165,16 +137,6 @@ ___Since v0.1___ {{ amount_from_asset asset }} --> '2.001'. ``` -* `symbol_name_from_asset` - _(__Deprecated__ Use `asset_to_symbol_code` instead.)_ Given a variable containing an asset, extract and return the symbol name. - - Example: - ``` - Given: - asset = '2.001 EOS' - - {{ symbol_name_from_asset asset }} --> 'EOS'. - ``` - ___Since v0.2___ * `to_json` - Takes the given variable and renders it as a preformatted JSON string. Note that the resulting string is also surrounded by `
` tags as well. This is intended as a debugging aid.
 
@@ -206,7 +168,7 @@ ___Since v0.2___
     Render if myVar is undefined or null
   {{/if_has_value}}
   ```
-#### HTML in variables
+#### HTML in Variables
 
 By default, any `{{variables}}` that contain HTML will have that HTML escaped. This may not be the desired outcome, as the `ricardian_clauses` may have HTML that the author wants rendered rather than escaped.