adobe / htl-spec

HTML Template Language Specification
Apache License 2.0
280 stars 146 forks source link

Clarify syntax of HTL block statements with respect to quoting of values #82

Closed kwin closed 2 years ago

kwin commented 5 years ago

According to https://html.spec.whatwg.org/multipage/introduction.html#intro-early-example HTML attribute values must be either

  1. Quoted in double quotes
  2. Quoted in single quotes
  3. Not quoted.

The HTL spec at https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#21-syntax should explicitly state which form is supported!

kwin commented 5 years ago

The Sling Sightly Compiler seems to understand all formats of attribute values: https://github.com/apache/sling-org-apache-sling-scripting-sightly-compiler/blob/01a7b922d5c2f89974534cdeba0c8373d92a24c1/src/main/java/org/apache/sling/scripting/sightly/impl/html/dom/TagTokenizer.java#L203

karollewandowski commented 4 years ago

I'm not sure that not quoted values are fully supported in Sightly. I'm playing with it now and here are results:

<sly data-sly-text=${15}></sly> // OK, prints "15"
<sly data-sly-text=${true}></sly> // OK, prints "true"
<sly data-sly-text=${'text'}></sly> // ERROR 500

I'm getting error 500 for other blocks as well (data-sly-use, data-sly-test, etc). Error occurs when expression contains string literal or any expression being non-literal (eg. 15 > 2, true || false, true ? 'a' : 'b'). I know it is a part of Sightly implementation and not related to HTL specification, but maybe it will somehow help in spec as well. If not quoted values should be supported, then let me know to raise issue in Sightly implementation.

Clarification would be very useful.

raducotescu commented 2 years ago

@karollewandowski, I think you discovered a bug in the Sling implementation.

However, what @kwin mentions is valid. HTL is built on top of HTML, so the specification should be explicit when it comes to the attribute values.