htl-spec icon indicating copy to clipboard operation
htl-spec copied to clipboard

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

Open kwin opened this issue 6 years ago • 2 comments

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 avatar May 06 '19 11:05 kwin

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

kwin avatar May 06 '19 11:05 kwin

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.

karollewandowski avatar Mar 17 '20 18:03 karollewandowski

@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.

raducotescu avatar Aug 17 '22 14:08 raducotescu