[
https://issues.apache.org/jira/browse/SLING-4443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17446808#comment-17446808
]
Konrad Windszus edited comment on SLING-4443 at 11/22/21, 4:55 PM:
-------------------------------------------------------------------
I think there are three different implementation possibilities:
# Generic servlet filter for any HTML responses (like
https://balusc.omnifaces.org/2007/12/whitespacefilter.html)
# Tie it to HTL compiler with a {{CommandHandler}} implementation
(https://github.com/apache/sling-org-apache-sling-scripting-sightly-compiler/blob/7244040a67824ffb945219f8273e4505cd03b750/src/main/java/org/apache/sling/scripting/sightly/compiler/commands/CommandHandler.java#L28)
like proposed by [~diru]
# Make it part of the pipeline generator
To better detect if output was generated by scripting languages a special
request attribute may be set to {{true}} in case any output has been generated
by a scripting engine.
In any case the implementation from Jasper
(https://github.com/apache/tomcat/blob/f9e8d2b09f9e9a6c02c674c1464fb5abf68fb000/java/org/apache/jasper/compiler/TextOptimizer.java#L85)
might act as a good inspiration source. Here is a good explanation where
whitespace is not relevant for rendering of the HTML:
https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace
was (Author: kwin):
I think there are two different implementation possibilities:
# Generic servlet filter for any HTML responses (like
https://balusc.omnifaces.org/2007/12/whitespacefilter.html)
# Tie it to HTL compiler with a {{CommandHandler}} implementation
(https://github.com/apache/sling-org-apache-sling-scripting-sightly-compiler/blob/7244040a67824ffb945219f8273e4505cd03b750/src/main/java/org/apache/sling/scripting/sightly/compiler/commands/CommandHandler.java#L28)
like proposed by [~diru]
In any case the implementation from Jasper
(https://github.com/apache/tomcat/blob/f9e8d2b09f9e9a6c02c674c1464fb5abf68fb000/java/org/apache/jasper/compiler/TextOptimizer.java#L85)
might act as a good inspiration source. Here is a good explanation where
whitespace is not relevant for rendering of the HTML:
https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace
> Whitespace removal for Sightly HTML output
> ------------------------------------------
>
> Key: SLING-4443
> URL: https://issues.apache.org/jira/browse/SLING-4443
> Project: Sling
> Issue Type: New Feature
> Components: Scripting
> Affects Versions: Scripting Sightly Engine 1.0.0
> Reporter: Dan Chapman
> Priority: Minor
> Time Spent: 1h
> Remaining Estimate: 0h
>
> Can there be a way to remove whitespace from Sightly components HTML output,
> that is created when elements are hidden e.g. <span data-sly-test="..."
> Previously in JSPs we could use - trimDirectiveWhitespaces="true"
--
This message was sent by Atlassian Jira
(v8.20.1#820001)