You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Konrad Windszus (Jira)" <ji...@apache.org> on 2022/10/04 10:36:00 UTC

[jira] [Comment Edited] (SLING-11538) Add display context for JSON string

    [ https://issues.apache.org/jira/browse/SLING-11538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17597868#comment-17597868 ] 

Konrad Windszus edited comment on SLING-11538 at 10/4/22 10:35 AM:
-------------------------------------------------------------------

The use case is inline JSON in HTML. Writing that in Java methods is for sure possible but breaks the model/view separation from my PoV. The JSON can be generated far easier in HTL if just that missing context is added.
I am gonna improve the test case to show a more realistic scenario where the same getter method is used in both regular HTML and in inline JSON values (https://developers.google.com/search/docs/appearance/structured-data/faqpage).


was (Author: kwin):
The use case is inline JSON in HTML. Writing that in Java methods is for sure possible but breaks the model/view separation from my PoV. The JSON can be generated far easier in HTL if just that missing context is added.
I am gonna improve the test case to show a more realistic scenario where the same getter method is used in both regular HTML and in inline JSON values.

> Add display context for JSON string
> -----------------------------------
>
>                 Key: SLING-11538
>                 URL: https://issues.apache.org/jira/browse/SLING-11538
>             Project: Sling
>          Issue Type: Improvement
>          Components: HTL
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>            Priority: Major
>             Fix For: Scripting HTL Engine 1.4.22-1.4.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> It would be useful to add an output context to HTL to be used inside JSON. As JSON is very complex, the most essential one which currently cannot be achieved with any other existing contexts is escaping for a JSON String value (compare with https://github.com/adobe/htl-spec/issues/5).
> I propose to introduce a new context {{jsonString}} next to {{scriptString}} in https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/192d953514e6e579428cda157a7e83fc2a05cc01/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/XSSRuntimeExtension.java#L93.
> As it is not part of the official HTL spec at https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#121-display-context it needs to be listed as Sling-specific addition in https://sling.apache.org/documentation/bundles/scripting/scripting-htl.html#extensions-of-the-htl-specification.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)